From 88b3975802d46380ac29a19433d54f3ed489a9c1 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sun, 9 Jul 2023 21:17:55 +0800 Subject: [PATCH] fix(node): guard error info --- packages/vitest/src/node/error.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/vitest/src/node/error.ts b/packages/vitest/src/node/error.ts index b099cb068e1b..98d097d3b79f 100644 --- a/packages/vitest/src/node/error.ts +++ b/packages/vitest/src/node/error.ts @@ -191,6 +191,10 @@ export function displayDiff(diff: string | null, console: Console) { function printErrorMessage(error: ErrorWithDiff, logger: Logger) { const errorName = error.name || error.nameStr || 'Unknown Error' + if (!(error instanceof Error)) { + logger.error(error) + return + } if (error.message.length > 5000) { // Protect against infinite stack trace in picocolors logger.error(`${c.red(c.bold(errorName))}: ${error.message}`)