Skip to content

Commit

Permalink
fix: add a fallback if error fails to serialize (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Feb 1, 2022
1 parent 5ef622a commit c68fce4
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 c68fce4

Please sign in to comment.