Skip to content

Commit

Permalink
Clean error messages (fix #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt committed Sep 11, 2023
1 parent f4d121c commit 8558dfd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/Blocks/SmartViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function SmartViewer({
compact = false,
}: {
data: any
error?: string
error?: any
compact?: boolean
}) {
const parsed = useMemo(() => {
Expand Down Expand Up @@ -64,7 +64,13 @@ export default function SmartViewer({
{error && (
<pre>
<Code color="red">
{typeof error === "object" ? JSON.stringify(error, null, 2) : error}
{typeof error.stack === "string"
? compact
? error.message || error.stack
: error.stack
: typeof error === "object"
? JSON.stringify(error, null, 2)
: error}
</Code>
</pre>
)}
Expand Down

0 comments on commit 8558dfd

Please sign in to comment.