Skip to content

Commit 5c42419

Browse files
committed
Strip Raven's wrapped try/catch call from frames
1 parent 6bed42f commit 5c42419

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
@@ -265,7 +265,7 @@ Raven.prototype = {
265265
return func.apply(this, args);
266266
} catch(e) {
267267
self._ignoreNextOnError();
268-
self.captureException(e, options);
268+
self.captureException(e, options, 1);
269269
throw e;
270270
}
271271
}
@@ -310,9 +310,11 @@ Raven.prototype = {
310310
* @param {object} options A specific set of options for this error [optional]
311311
* @return {Raven}
312312
*/
313-
captureException: function(ex, options) {
313+
captureException: function(ex, options, skipframes) {
314+
skipframes = skipframes || 0;
315+
314316
// If not an Error is passed through, recall as a message instead
315-
if (!isError(ex)) return this.captureMessage(ex, options);
317+
if (!isError(ex)) return this.captureMessage(ex, options, skipframes + 1);
316318

317319
// Store the raw exception object for potential debugging and introspection
318320
this._lastCapturedException = ex;
@@ -324,7 +326,7 @@ Raven.prototype = {
324326
// report on.
325327
try {
326328
var stack = TraceKit.computeStackTrace(ex);
327-
this._handleStackInfo(stack, options);
329+
this._handleStackInfo(stack, options, skipframes);
328330
} catch(ex1) {
329331
if(ex !== ex1) {
330332
throw ex1;
@@ -341,7 +343,7 @@ Raven.prototype = {
341343
* @param {object} options A specific set of options for this message [optional]
342344
* @return {Raven}
343345
*/
344-
captureMessage: function(msg, options) {
346+
captureMessage: function(msg, options, skipframes) {
345347
// config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
346348
// early call; we'll error on the side of logging anything called before configuration since it's
347349
// probably something you should see:
@@ -1005,7 +1007,7 @@ Raven.prototype = {
10051007
}
10061008
},
10071009

1008-
_handleStackInfo: function(stackInfo, options) {
1010+
_handleStackInfo: function(stackInfo, options, skipframes) {
10091011
var self = this;
10101012
var frames = [];
10111013

@@ -1016,6 +1018,10 @@ Raven.prototype = {
10161018
frames.push(frame);
10171019
}
10181020
});
1021+
1022+
if (skipframes) {
1023+
frames = frames.slice(0, skipframes);
1024+
}
10191025
}
10201026

10211027
this._triggerEvent('handle', {

0 commit comments

Comments
 (0)