Skip to content

Commit

Permalink
Fix non-error throws on onerror handler on Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Sep 6, 2017
1 parent 270c55b commit f8ac9e2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ Raven.prototype = {
var frames = [];
if (stackInfo.stack && stackInfo.stack.length) {
each(stackInfo.stack, function(i, stack) {
var frame = self._normalizeFrame(stack);
var frame = self._normalizeFrame(stack, stackInfo.url);
if (frame) {
frames.push(frame);
}
Expand All @@ -1386,8 +1386,21 @@ Raven.prototype = {
return frames;
},

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

// normalize the frames data
var normalized = {
Expand Down

0 comments on commit f8ac9e2

Please sign in to comment.