Skip to content

Commit 0362926

Browse files
zivlkamilogorek
authored andcommitted
check for both stacktraces before calling 'isSameException'
1 parent 104217a commit 0362926

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,13 @@ function isOnlyOneTruthy(a, b) {
322322
return !!(!!a ^ !!b);
323323
}
324324

325+
/**
326+
* Returns true if both parameters are undefined
327+
*/
328+
function isBothUndefined(a, b) {
329+
return isUndefined(a) && isUndefined(b);
330+
}
331+
325332
/**
326333
* Returns true if the two input exception interfaces have the same content
327334
*/
@@ -333,6 +340,9 @@ function isSameException(ex1, ex2) {
333340

334341
if (ex1.type !== ex2.type || ex1.value !== ex2.value) return false;
335342

343+
// in case both stacktraces are undefined, we can't decide so default to false
344+
if (isBothUndefined(ex1.stacktrace, ex2.stacktrace)) return false;
345+
336346
return isSameStacktrace(ex1.stacktrace, ex2.stacktrace);
337347
}
338348

test/raven.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,6 +3527,14 @@ describe('Raven (private methods)', function() {
35273527
data.exception.values[0].stacktrace.frames = [];
35283528
assert.isFalse(Raven._isRepeatData(data));
35293529
});
3530+
3531+
it('should not blown if both stacktraces are undefined', function() {
3532+
Raven._lastData.exception.values[0].stacktrace = undefined;
3533+
var data1 = JSON.parse(JSON.stringify(Raven._lastData)); // copy
3534+
var data2 = JSON.parse(JSON.stringify(Raven._lastData)); // copy
3535+
assert.isFalse(Raven._isRepeatData(data1));
3536+
assert.isFalse(Raven._isRepeatData(data2));
3537+
});
35303538
});
35313539
});
35323540
});

0 commit comments

Comments
 (0)