@@ -341,7 +341,18 @@ Raven.prototype = {
341
341
* @return {Raven }
342
342
*/
343
343
captureMessage : function ( msg , options ) {
344
- if ( options . stacktrace ) {
344
+ // config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
345
+ // early call; we'll error on the side of logging anything called before configuration since it's
346
+ // probably something you should see:
347
+ if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( msg ) ) {
348
+ return ;
349
+ }
350
+
351
+ var data = objectMerge ( {
352
+ message : msg + '' // Make sure it's actually a string
353
+ } , options ) ;
354
+
355
+ if ( options && options . stacktrace ) {
345
356
var ex ;
346
357
// create a stack trace from this point; just trim
347
358
// off extra frames so they don't include this function call (or
@@ -363,26 +374,16 @@ Raven.prototype = {
363
374
trimTailFrames : ( options . trimHeadFrames || 0 ) + 1
364
375
} , options ) ;
365
376
366
- // infinite loop if ex *somehow* returns false for isError
367
- // is that possible when it is result of try/catch?
368
- this . captureException ( ex , options ) ;
369
-
370
- return this ;
371
- }
372
-
373
- // config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
374
- // early call; we'll error on the side of logging anything called before configuration since it's
375
- // probably something you should see:
376
- if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( msg ) ) {
377
- return ;
377
+ var stack = TraceKit . computeStackTrace ( ex ) ;
378
+ var frames = this . _buildNormalizedFrames ( stack , options ) ;
379
+ data . stacktrace = {
380
+ // Sentry expects frames oldest to newest
381
+ frames : frames . reverse ( )
382
+ }
378
383
}
379
384
380
385
// Fire away!
381
- this . _send (
382
- objectMerge ( {
383
- message : msg + '' // Make sure it's actually a string
384
- } , options )
385
- ) ;
386
+ this . _send ( data ) ;
386
387
387
388
return this ;
388
389
} ,
@@ -1053,9 +1054,26 @@ Raven.prototype = {
1053
1054
} ,
1054
1055
1055
1056
_handleStackInfo : function ( stackInfo , options ) {
1057
+ var frames = this . _prepareFrames ( stackInfo , options ) ;
1058
+
1059
+ this . _triggerEvent ( 'handle' , {
1060
+ stackInfo : stackInfo ,
1061
+ options : options
1062
+ } ) ;
1063
+
1064
+ this . _processException (
1065
+ stackInfo . name ,
1066
+ stackInfo . message ,
1067
+ stackInfo . url ,
1068
+ stackInfo . lineno ,
1069
+ frames ,
1070
+ options
1071
+ ) ;
1072
+ } ,
1073
+
1074
+ _prepareFrames : function ( stackInfo , options ) {
1056
1075
var self = this ;
1057
1076
var frames = [ ] ;
1058
-
1059
1077
if ( stackInfo . stack && stackInfo . stack . length ) {
1060
1078
each ( stackInfo . stack , function ( i , stack ) {
1061
1079
var frame = self . _normalizeFrame ( stack ) ;
@@ -1065,30 +1083,25 @@ Raven.prototype = {
1065
1083
} ) ;
1066
1084
1067
1085
// e.g. frames captured via captureMessage throw
1068
- if ( options . trimHeadFrames ) {
1069
- frames = frames . slice ( options . trimHeadFrames ) ;
1086
+ var j ;
1087
+ if ( options && options . trimHeadFrames ) {
1088
+ for ( j = 0 ; j < options . trimHeadFrames && j < frames . length ; j ++ ) {
1089
+ frames [ j ] . in_app = true ;
1090
+ }
1070
1091
}
1092
+
1071
1093
// e.g. try/catch (wrapper) frames
1072
- if ( options . trimTailFrames ) {
1073
- frames = frames . slice ( 0 , options . trimTailFrames ) ;
1094
+ if ( options && options . trimTailFrames ) {
1095
+ for ( j = options . trimTailFrames ; j < frames . length ; j ++ ) {
1096
+ frames [ j ] . in_app = true ;
1097
+ }
1074
1098
}
1075
1099
}
1076
-
1077
- this . _triggerEvent ( 'handle' , {
1078
- stackInfo : stackInfo ,
1079
- options : options
1080
- } ) ;
1081
-
1082
- this . _processException (
1083
- stackInfo . name ,
1084
- stackInfo . message ,
1085
- stackInfo . url ,
1086
- stackInfo . lineno ,
1087
- frames . slice ( 0 , this . _globalOptions . stackTraceLimit ) ,
1088
- options
1089
- ) ;
1100
+ frames = frames . slice ( 0 , this . _globalOptions . stackTraceLimit ) ;
1101
+ return frames ;
1090
1102
} ,
1091
1103
1104
+
1092
1105
_normalizeFrame : function ( frame ) {
1093
1106
if ( ! frame . url ) return ;
1094
1107
@@ -1114,7 +1127,6 @@ Raven.prototype = {
1114
1127
1115
1128
_processException : function ( type , message , fileurl , lineno , frames , options ) {
1116
1129
var stacktrace ;
1117
-
1118
1130
if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( message ) ) return ;
1119
1131
1120
1132
message += '' ;
0 commit comments