Skip to content

Commit

Permalink
Improve callsite handling
Browse files Browse the repository at this point in the history
Fixes #2744.
  • Loading branch information
Fem-Fem committed May 9, 2021
1 parent e9a69dc commit b8f5685
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/serialize-error.js
Expand Up @@ -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;
Expand Down

0 comments on commit b8f5685

Please sign in to comment.