Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: don't stop watch mode, if non-object error is thrown, close #2106
  • Loading branch information
sheremet-va committed Oct 5, 2022
1 parent ef12e96 commit bd67701
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/vitest/src/node/error.ts
Expand Up @@ -35,6 +35,14 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro
} as any
}

if (!e) {
const error = new Error('unknown error')
e = {
message: e ?? error.message,
stack: error.stack,
} as any
}

const stacks = parseStacktrace(e, fullStack)

await interpretSourcePos(stacks, ctx)
Expand Down
3 changes: 3 additions & 0 deletions packages/vitest/src/utils/source-map.ts
Expand Up @@ -57,6 +57,9 @@ function extractLocation(urlLike: string) {
}

export function parseStacktrace(e: ErrorWithDiff, full = false): ParsedStack[] {
if (!e)
return []

if (e.stacks)
return e.stacks

Expand Down

0 comments on commit bd67701

Please sign in to comment.