Skip to content

Commit bd67701

Browse files
committed
fix: don't stop watch mode, if non-object error is thrown, close #2106
1 parent ef12e96 commit bd67701

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/vitest/src/node/error.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export async function printError(error: unknown, ctx: Vitest, options: PrintErro
3535
} as any
3636
}
3737

38+
if (!e) {
39+
const error = new Error('unknown error')
40+
e = {
41+
message: e ?? error.message,
42+
stack: error.stack,
43+
} as any
44+
}
45+
3846
const stacks = parseStacktrace(e, fullStack)
3947

4048
await interpretSourcePos(stacks, ctx)

packages/vitest/src/utils/source-map.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ function extractLocation(urlLike: string) {
5757
}
5858

5959
export function parseStacktrace(e: ErrorWithDiff, full = false): ParsedStack[] {
60+
if (!e)
61+
return []
62+
6063
if (e.stacks)
6164
return e.stacks
6265

0 commit comments

Comments
 (0)