Skip to content

Commit 4c5da1b

Browse files
committed
Dont rely on TraceKit.report for captureException
1 parent d5561fb commit 4c5da1b

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/raven.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ var Raven = {
243243
// raises an exception different from the one we asked to
244244
// report on.
245245
try {
246-
TraceKit.report(ex, options);
246+
var stack = TraceKit.computeStackTrace(ex);
247+
handleStackInfo(stack, options);
247248
} catch(ex1) {
248249
if(ex !== ex1) {
249250
throw ex1;

test/raven.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ describe('Raven (public API)', function() {
15121512

15131513
it('should re-raise a thrown exception', function() {
15141514
var error = new Error('lol');
1515+
this.sinon.stub(Raven, 'captureException');
15151516
assert.throws(function() {
15161517
Raven.wrap(function() { throw error; })();
15171518
}, error);
@@ -1728,46 +1729,45 @@ describe('Raven (public API)', function() {
17281729
});
17291730

17301731
describe('.captureException', function() {
1731-
it('should call TraceKit.report', function() {
1732+
it('should call handleStackInfo', function() {
17321733
var error = new Error('crap');
1733-
this.sinon.stub(TraceKit, 'report');
1734+
this.sinon.stub(window, 'handleStackInfo');
17341735
Raven.captureException(error, {foo: 'bar'});
1735-
assert.isTrue(TraceKit.report.calledOnce);
1736-
assert.deepEqual(TraceKit.report.lastCall.args, [error, {foo: 'bar'}]);
1736+
assert.isTrue(window.handleStackInfo.calledOnce);
17371737
});
17381738

17391739
it('should store the last exception', function() {
17401740
var error = new Error('crap');
1741-
this.sinon.stub(TraceKit, 'report');
1741+
this.sinon.stub(window, 'handleStackInfo');
17421742
Raven.captureException(error);
17431743
assert.equal(Raven.lastException(), error);
17441744
});
17451745

17461746
it('shouldn\'t reraise the if the error is the same error', function() {
17471747
var error = new Error('crap');
1748-
this.sinon.stub(TraceKit, 'report').throws(error);
1748+
this.sinon.stub(window, 'handleStackInfo').throws(error);
17491749
// this would raise if the errors didn't match
17501750
Raven.captureException(error, {foo: 'bar'});
1751-
assert.isTrue(TraceKit.report.calledOnce);
1751+
assert.isTrue(window.handleStackInfo.calledOnce);
17521752
});
17531753

17541754
it('should reraise a different error', function() {
17551755
var error = new Error('crap1');
1756-
this.sinon.stub(TraceKit, 'report').throws(error);
1756+
this.sinon.stub(window, 'handleStackInfo').throws(error);
17571757
assert.throws(function() {
17581758
Raven.captureException(new Error('crap2'));
17591759
}, error);
17601760
});
17611761

17621762
it('should capture as a normal message if a non-Error is passed', function() {
17631763
this.sinon.stub(Raven, 'captureMessage');
1764-
this.sinon.stub(TraceKit, 'report');
1764+
this.sinon.stub(window, 'handleStackInfo')
17651765
Raven.captureException('derp');
17661766
assert.equal(Raven.captureMessage.lastCall.args[0], 'derp');
1767-
assert.isFalse(TraceKit.report.called);
1767+
assert.isFalse(window.handleStackInfo.called);
17681768
Raven.captureException(true);
17691769
assert.equal(Raven.captureMessage.lastCall.args[0], true);
1770-
assert.isFalse(TraceKit.report.called);
1770+
assert.isFalse(window.handleStackInfo.called);
17711771
});
17721772
});
17731773

0 commit comments

Comments
 (0)