@@ -438,39 +438,7 @@ Raven.prototype = {
438
438
) ;
439
439
440
440
if ( this . _globalOptions . stacktrace || ( options && options . stacktrace ) ) {
441
- var ex ;
442
- // Generate a "synthetic" stack trace from this point.
443
- // NOTE: If you are a Sentry user, and you are seeing this stack frame, it is NOT indicative
444
- // of a bug with Raven.js. Sentry generates synthetic traces either by configuration,
445
- // or if it catches a thrown object without a "stack" property.
446
- try {
447
- throw new Error ( msg ) ;
448
- } catch ( ex1 ) {
449
- ex = ex1 ;
450
- }
451
-
452
- // null exception name so `Error` isn't prefixed to msg
453
- ex . name = null ;
454
-
455
- options = objectMerge (
456
- {
457
- // fingerprint on msg, not stack trace (legacy behavior, could be
458
- // revisited)
459
- fingerprint : msg ,
460
- // since we know this is a synthetic trace, the top N-most frames
461
- // MUST be from Raven.js, so mark them as in_app later by setting
462
- // trimHeadFrames
463
- trimHeadFrames : ( options . trimHeadFrames || 0 ) + 1
464
- } ,
465
- options
466
- ) ;
467
-
468
- var stack = TraceKit . computeStackTrace ( ex ) ;
469
- var frames = this . _prepareFrames ( stack , options ) ;
470
- data . stacktrace = {
471
- // Sentry expects frames oldest to newest
472
- frames : frames . reverse ( )
473
- } ;
441
+ data . stacktrace = this . _generateSyntheticStacktrace ( msg , options ) ;
474
442
}
475
443
476
444
// Fire away!
@@ -1471,6 +1439,45 @@ Raven.prototype = {
1471
1439
this . _send ( data ) ;
1472
1440
} ,
1473
1441
1442
+ _generateSyntheticStacktrace : function ( msg , options ) {
1443
+ options = options || { } ;
1444
+
1445
+ var ex ;
1446
+ // Generate a "synthetic" stack trace from this point.
1447
+ // NOTE: If you are a Sentry user, and you are seeing this stack frame, it is NOT indicative
1448
+ // of a bug with Raven.js. Sentry generates synthetic traces either by configuration,
1449
+ // or if it catches a thrown object without a "stack" property.
1450
+ try {
1451
+ throw new Error ( msg ) ;
1452
+ } catch ( ex1 ) {
1453
+ ex = ex1 ;
1454
+ }
1455
+
1456
+ // null exception name so `Error` isn't prefixed to msg
1457
+ ex . name = null ;
1458
+
1459
+ options = objectMerge (
1460
+ {
1461
+ // fingerprint on msg, not stack trace (legacy behavior, could be
1462
+ // revisited)
1463
+ fingerprint : msg ,
1464
+ // since we know this is a synthetic trace, the top N-most frames
1465
+ // MUST be from Raven.js, so mark them as in_app later by setting
1466
+ // trimHeadFrames
1467
+ trimHeadFrames : ( options . trimHeadFrames || 0 ) + 1
1468
+ } ,
1469
+ options
1470
+ ) ;
1471
+
1472
+ var stack = TraceKit . computeStackTrace ( ex ) ;
1473
+ var frames = this . _prepareFrames ( stack , options ) ;
1474
+ return {
1475
+ // Sentry expects frames oldest to newest
1476
+ // We also remove _generateSyntheticStacktrace call itself from the stack
1477
+ frames : frames . slice ( 1 ) . reverse ( )
1478
+ } ;
1479
+ } ,
1480
+
1474
1481
_trimPacket : function ( data ) {
1475
1482
// For now, we only want to truncate the two different messages
1476
1483
// but this could/should be expanded to just trim everything
0 commit comments