Skip to content

Commit

Permalink
fix: add a fallback if error fails to serialize
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Jan 29, 2022
1 parent 022f561 commit 61519c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vitest/src/runtime/error.ts
Expand Up @@ -62,5 +62,10 @@ export function processError(err: any) {
if (typeof err.actual !== 'string')
err.actual = stringify(err.actual)

return serializeError(err)
try {
return serializeError(err)
}
catch (e: any) {
return serializeError(new Error(`Failed to fully serialize error: ${e?.message}.\nInner error message: ${err?.message}`))
}
}

0 comments on commit 61519c2

Please sign in to comment.