Skip to content

Commit 76ee66c

Browse files
committed
fix: Gracefuly handle incorrect input from onerror
1 parent a909d94 commit 76ee66c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,17 @@ export class GlobalHandlers implements Integration {
240240
event.exception.values[0].stacktrace = event.exception.values[0].stacktrace || {};
241241
event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames || [];
242242

243+
const colno = isNaN(parseInt(column, 10)) ? undefined : column;
244+
const lineno = isNaN(parseInt(line, 10)) ? undefined : line;
245+
const filename = isString(url) ? url : getLocationHref();
246+
243247
if (event.exception.values[0].stacktrace.frames.length === 0) {
244248
event.exception.values[0].stacktrace.frames.push({
245-
colno: column,
246-
filename: url || getLocationHref(),
249+
colno,
250+
filename,
247251
function: '?',
248252
in_app: true,
249-
lineno: line,
253+
lineno,
250254
});
251255
}
252256

0 commit comments

Comments
 (0)