@@ -362,7 +362,18 @@ Raven.prototype = {
362
362
* @return {Raven }
363
363
*/
364
364
captureMessage : function ( msg , options ) {
365
- if ( options . stacktrace ) {
365
+ // config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
366
+ // early call; we'll error on the side of logging anything called before configuration since it's
367
+ // probably something you should see:
368
+ if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( msg ) ) {
369
+ return ;
370
+ }
371
+
372
+ var data = objectMerge ( {
373
+ message : msg + '' // Make sure it's actually a string
374
+ } , options ) ;
375
+
376
+ if ( options && options . stacktrace ) {
366
377
var ex ;
367
378
// create a stack trace from this point; just trim
368
379
// off extra frames so they don't include this function call (or
@@ -384,26 +395,16 @@ Raven.prototype = {
384
395
trimTailFrames : ( options . trimHeadFrames || 0 ) + 1
385
396
} , options ) ;
386
397
387
- // infinite loop if ex *somehow* returns false for isError
388
- // is that possible when it is result of try/catch?
389
- this . captureException ( ex , options ) ;
390
-
391
- return this ;
392
- }
393
-
394
- // config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
395
- // early call; we'll error on the side of logging anything called before configuration since it's
396
- // probably something you should see:
397
- if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( msg ) ) {
398
- return ;
398
+ var stack = TraceKit . computeStackTrace ( ex ) ;
399
+ var frames = this . _buildNormalizedFrames ( stack , options ) ;
400
+ data . stacktrace = {
401
+ // Sentry expects frames oldest to newest
402
+ frames : frames . reverse ( )
403
+ }
399
404
}
400
405
401
406
// Fire away!
402
- this . _send (
403
- objectMerge ( {
404
- message : msg + '' // Make sure it's actually a string
405
- } , options )
406
- ) ;
407
+ this . _send ( data ) ;
407
408
408
409
return this ;
409
410
} ,
@@ -1101,9 +1102,26 @@ Raven.prototype = {
1101
1102
} ,
1102
1103
1103
1104
_handleStackInfo : function ( stackInfo , options ) {
1105
+ var frames = this . _prepareFrames ( stackInfo , options ) ;
1106
+
1107
+ this . _triggerEvent ( 'handle' , {
1108
+ stackInfo : stackInfo ,
1109
+ options : options
1110
+ } ) ;
1111
+
1112
+ this . _processException (
1113
+ stackInfo . name ,
1114
+ stackInfo . message ,
1115
+ stackInfo . url ,
1116
+ stackInfo . lineno ,
1117
+ frames ,
1118
+ options
1119
+ ) ;
1120
+ } ,
1121
+
1122
+ _prepareFrames : function ( stackInfo , options ) {
1104
1123
var self = this ;
1105
1124
var frames = [ ] ;
1106
-
1107
1125
if ( stackInfo . stack && stackInfo . stack . length ) {
1108
1126
each ( stackInfo . stack , function ( i , stack ) {
1109
1127
var frame = self . _normalizeFrame ( stack ) ;
@@ -1113,30 +1131,25 @@ Raven.prototype = {
1113
1131
} ) ;
1114
1132
1115
1133
// e.g. frames captured via captureMessage throw
1116
- if ( options . trimHeadFrames ) {
1117
- frames = frames . slice ( options . trimHeadFrames ) ;
1134
+ var j ;
1135
+ if ( options && options . trimHeadFrames ) {
1136
+ for ( j = 0 ; j < options . trimHeadFrames && j < frames . length ; j ++ ) {
1137
+ frames [ j ] . in_app = true ;
1138
+ }
1118
1139
}
1140
+
1119
1141
// e.g. try/catch (wrapper) frames
1120
- if ( options . trimTailFrames ) {
1121
- frames = frames . slice ( 0 , options . trimTailFrames ) ;
1142
+ if ( options && options . trimTailFrames ) {
1143
+ for ( j = options . trimTailFrames ; j < frames . length ; j ++ ) {
1144
+ frames [ j ] . in_app = true ;
1145
+ }
1122
1146
}
1123
1147
}
1124
-
1125
- this . _triggerEvent ( 'handle' , {
1126
- stackInfo : stackInfo ,
1127
- options : options
1128
- } ) ;
1129
-
1130
- this . _processException (
1131
- stackInfo . name ,
1132
- stackInfo . message ,
1133
- stackInfo . url ,
1134
- stackInfo . lineno ,
1135
- frames . slice ( 0 , this . _globalOptions . stackTraceLimit ) ,
1136
- options
1137
- ) ;
1148
+ frames = frames . slice ( 0 , this . _globalOptions . stackTraceLimit ) ;
1149
+ return frames ;
1138
1150
} ,
1139
1151
1152
+
1140
1153
_normalizeFrame : function ( frame ) {
1141
1154
if ( ! frame . url ) return ;
1142
1155
@@ -1162,7 +1175,6 @@ Raven.prototype = {
1162
1175
1163
1176
_processException : function ( type , message , fileurl , lineno , frames , options ) {
1164
1177
var stacktrace ;
1165
-
1166
1178
if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( message ) ) return ;
1167
1179
1168
1180
message += '' ;
0 commit comments