From b8f5685ed5b828de884d0d72c988efe837058692 Mon Sep 17 00:00:00 2001 From: Obafemi Fadairo Date: Sun, 9 May 2021 14:35:36 -0400 Subject: [PATCH] Improve callsite handling Fixes #2744. --- lib/serialize-error.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/serialize-error.js b/lib/serialize-error.js index ddd39ff2b..579f2f983 100644 --- a/lib/serialize-error.js +++ b/lib/serialize-error.js @@ -26,17 +26,15 @@ function extractSource(stack, testFile) { const relFile = path.relative(process.cwd(), testFile); const normalizedFile = process.platform === 'win32' ? slash(relFile) : relFile; for (const line of stack.split('\n')) { - try { - const callSite = stackUtils.parseLine(line); - if (callSite.file === normalizedFile) { - return { - isDependency: false, - isWithinProject: true, - file: path.resolve(process.cwd(), callSite.file), - line: callSite.line - }; - } - } catch {} + const callSite = stackUtils.parseLine(line); + if (callSite && callSite.file === normalizedFile) { + return { + isDependency: false, + isWithinProject: true, + file: path.resolve(process.cwd(), callSite.file), + line: callSite.line + }; + } } return null;