Skip to content

Commit b8f5685

Browse files
authored
Improve callsite handling
Fixes #2744.
1 parent e9a69dc commit b8f5685

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/serialize-error.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,15 @@ function extractSource(stack, testFile) {
2626
const relFile = path.relative(process.cwd(), testFile);
2727
const normalizedFile = process.platform === 'win32' ? slash(relFile) : relFile;
2828
for (const line of stack.split('\n')) {
29-
try {
30-
const callSite = stackUtils.parseLine(line);
31-
if (callSite.file === normalizedFile) {
32-
return {
33-
isDependency: false,
34-
isWithinProject: true,
35-
file: path.resolve(process.cwd(), callSite.file),
36-
line: callSite.line
37-
};
38-
}
39-
} catch {}
29+
const callSite = stackUtils.parseLine(line);
30+
if (callSite && callSite.file === normalizedFile) {
31+
return {
32+
isDependency: false,
33+
isWithinProject: true,
34+
file: path.resolve(process.cwd(), callSite.file),
35+
line: callSite.line
36+
};
37+
}
4038
}
4139

4240
return null;

0 commit comments

Comments
 (0)