From 1a97d4ee09407420e95dedaeaabe9388d20cb89b Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 1 Jul 2020 15:54:41 +0200 Subject: [PATCH] Handle anonymous stack frames correctly --- src/aggregrate-errors.js | 5 ++++- src/parse-stacktrace.js | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/aggregrate-errors.js b/src/aggregrate-errors.js index 2527e8d..a94e531 100644 --- a/src/aggregrate-errors.js +++ b/src/aggregrate-errors.js @@ -114,7 +114,10 @@ function removeInternalFrames(stack) { let internalBasePath = getInternalBasePath(); return stack.filter((frame) => { - return (!frame.location.path.startsWith(internalBasePath)); + return ( + !frame.location.anonymous + && !frame.location.path.startsWith(internalBasePath) + ); }); } diff --git a/src/parse-stacktrace.js b/src/parse-stacktrace.js index c3ab138..9c1e8bb 100644 --- a/src/parse-stacktrace.js +++ b/src/parse-stacktrace.js @@ -18,16 +18,20 @@ function maybeTrim(value) { } function parseLocation(locationString) { - let match = positionRegex.exec(locationString); - - if (match != null) { - return { - path: match[1], - line: parseInt(match[2]), - column: parseInt(match[3]) - }; + if (locationString === "") { + return { anonymous: true }; } else { - throw new Error(`Could not parse location from string: ${locationString}`); + let match = positionRegex.exec(locationString); + + if (match != null) { + return { + path: match[1], + line: parseInt(match[2]), + column: parseInt(match[3]) + }; + } else { + throw new Error(`Could not parse location from string: ${locationString}`); + } } }