Skip to content

Commit 99608a6

Browse files
committed
Strip Raven's wrapped try/catch call from frames
1 parent fbf1d1b commit 99608a6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/raven.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Raven.prototype = {
257257
return func.apply(this, args);
258258
} catch(e) {
259259
self._ignoreNextOnError();
260-
self.captureException(e, options);
260+
self.captureException(e, options, 1);
261261
throw e;
262262
}
263263
}
@@ -302,9 +302,11 @@ Raven.prototype = {
302302
* @param {object} options A specific set of options for this error [optional]
303303
* @return {Raven}
304304
*/
305-
captureException: function(ex, options) {
305+
captureException: function(ex, options, skipframes) {
306+
skipframes = skipframes || 0;
307+
306308
// If not an Error is passed through, recall as a message instead
307-
if (!isError(ex)) return this.captureMessage(ex, options);
309+
if (!isError(ex)) return this.captureMessage(ex, options, skipframes + 1);
308310

309311
// Store the raw exception object for potential debugging and introspection
310312
this._lastCapturedException = ex;
@@ -316,7 +318,7 @@ Raven.prototype = {
316318
// report on.
317319
try {
318320
var stack = TraceKit.computeStackTrace(ex);
319-
this._handleStackInfo(stack, options);
321+
this._handleStackInfo(stack, options, skipframes);
320322
} catch(ex1) {
321323
if(ex !== ex1) {
322324
throw ex1;
@@ -333,7 +335,7 @@ Raven.prototype = {
333335
* @param {object} options A specific set of options for this message [optional]
334336
* @return {Raven}
335337
*/
336-
captureMessage: function(msg, options) {
338+
captureMessage: function(msg, options, skipframes) {
337339
// config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
338340
// early call; we'll error on the side of logging anything called before configuration since it's
339341
// probably something you should see:
@@ -1010,7 +1012,7 @@ Raven.prototype = {
10101012
}
10111013
},
10121014

1013-
_handleStackInfo: function(stackInfo, options) {
1015+
_handleStackInfo: function(stackInfo, options, skipframes) {
10141016
var self = this;
10151017
var frames = [];
10161018

@@ -1021,6 +1023,10 @@ Raven.prototype = {
10211023
frames.push(frame);
10221024
}
10231025
});
1026+
1027+
if (skipframes) {
1028+
frames = frames.slice(0, skipframes);
1029+
}
10241030
}
10251031

10261032
this._triggerEvent('handle', {

0 commit comments

Comments
 (0)