Skip to content

Commit f8ac9e2

Browse files
committed
Fix non-error throws on onerror handler on Firefox
1 parent 270c55b commit f8ac9e2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/raven.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ Raven.prototype = {
13691369
var frames = [];
13701370
if (stackInfo.stack && stackInfo.stack.length) {
13711371
each(stackInfo.stack, function(i, stack) {
1372-
var frame = self._normalizeFrame(stack);
1372+
var frame = self._normalizeFrame(stack, stackInfo.url);
13731373
if (frame) {
13741374
frames.push(frame);
13751375
}
@@ -1386,8 +1386,21 @@ Raven.prototype = {
13861386
return frames;
13871387
},
13881388

1389-
_normalizeFrame: function(frame) {
1390-
if (!frame.url) return;
1389+
_normalizeFrame: function(frame, stackInfoUrl) {
1390+
if (!frame.url) {
1391+
// Case when we don't have any information about the error
1392+
// E.g. throwing a string or raw object in Firefox
1393+
// Generating synthetic error doesn't add any value here
1394+
//
1395+
// We should probably somehow let user know that he should fix his code
1396+
return {
1397+
filename: stackInfoUrl, // fallback to whole stacks url from onerror handler
1398+
lineno: frame.line,
1399+
colno: frame.column,
1400+
function: frame.func || '?', // if we dont have a file url, we most likely won't have a function name either
1401+
in_app: true // this will always come from the user's code
1402+
};
1403+
}
13911404

13921405
// normalize the frames data
13931406
var normalized = {

0 commit comments

Comments
 (0)