@@ -426,13 +426,31 @@ describe('addBody', function() {
426
426
expect ( i . stackInfo ) . to . be . ok ( ) ;
427
427
} ) ;
428
428
t . addBody ( item , options , function ( e , i ) {
429
- console . log ( 'body:' , i . data . body )
430
429
expect ( i . data . body . trace_chain . length ) . to . eql ( 2 ) ;
431
430
expect ( i . data . body . trace_chain [ 0 ] . exception . message ) . to . eql ( 'test error' ) ;
432
431
expect ( i . data . body . trace_chain [ 1 ] . exception . message ) . to . eql ( 'nested error' ) ;
433
432
done ( e ) ;
434
433
} ) ;
435
434
} ) ;
435
+ it ( 'should create add error context as custom data' , function ( done ) {
436
+ var nestedErr = new Error ( 'nested error' ) ;
437
+ nestedErr . rollbarContext = { err1 : 'nested context' } ;
438
+ var err = new Error ( 'test error' ) ;
439
+ err . rollbarContext = { err2 : 'error context' } ;
440
+ err . nested = nestedErr ;
441
+ var args = [ 'a message' , err ] ;
442
+ var item = itemFromArgs ( args ) ;
443
+ var options = { addErrorContext : true } ;
444
+ t . handleItemWithError ( item , options , function ( e , i ) {
445
+ expect ( i . stackInfo ) . to . be . ok ( ) ;
446
+ } ) ;
447
+ t . addBody ( item , options , function ( e , i ) {
448
+ expect ( i . data . body . trace_chain . length ) . to . eql ( 2 ) ;
449
+ expect ( i . data . custom . err1 ) . to . eql ( 'nested context' ) ;
450
+ expect ( i . data . custom . err2 ) . to . eql ( 'error context' ) ;
451
+ done ( e ) ;
452
+ } ) ;
453
+ } ) ;
436
454
} ) ;
437
455
} ) ;
438
456
0 commit comments