@@ -770,14 +770,14 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
770
770
// Note: Symbols are not supported by `Error#toString()` which is called by
771
771
// accessing the `stack` property.
772
772
[
773
- [ 404 , '404 [RangeError]: foo' , '[404]' ] ,
773
+ [ 404 , '404 [RangeError]: foo' , '[RangeError: foo\n 404]' ] ,
774
774
[ 0 , '0 [RangeError]: foo' , '[RangeError: foo]' ] ,
775
775
[ 0n , '0 [RangeError]: foo' , '[RangeError: foo]' ] ,
776
776
[ null , 'null: foo' , '[RangeError: foo]' ] ,
777
777
[ undefined , 'RangeError: foo' , '[RangeError: foo]' ] ,
778
778
[ false , 'false [RangeError]: foo' , '[RangeError: foo]' ] ,
779
779
[ '' , 'foo' , '[RangeError: foo]' ] ,
780
- [ [ 1 , 2 , 3 ] , '1,2,3 [RangeError]: foo' , '[[\n 1,\n 2,\n 3\n]]' ] ,
780
+ [ [ 1 , 2 , 3 ] , '1,2,3 [RangeError]: foo' , '[RangeError: foo\n [\n 1,\n 2,\n 3\n ]]' ] ,
781
781
] . forEach ( ( [ value , outputStart , stack ] ) => {
782
782
let err = new RangeError ( 'foo' ) ;
783
783
err . name = value ;
@@ -3425,6 +3425,34 @@ ${error.stack.split('\n').slice(1).join('\n')}`,
3425
3425
3426
3426
assert . strictEqual (
3427
3427
inspect ( error ) ,
3428
- '[[\n Symbol(foo)\n]]'
3428
+ '[Error\n [\n Symbol(foo)\n ]]'
3429
3429
) ;
3430
3430
}
3431
+
3432
+ {
3433
+ const prepareStackTrace = Error . prepareStackTrace ;
3434
+
3435
+ Error . prepareStackTrace = ( error ) => error ;
3436
+
3437
+ const error = new Error ( 'foo' ) ;
3438
+
3439
+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3440
+
3441
+ Error . prepareStackTrace = prepareStackTrace ;
3442
+ }
3443
+
3444
+ {
3445
+ const error = new Error ( 'foo' ) ;
3446
+ error . stack = error ;
3447
+
3448
+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3449
+ }
3450
+
3451
+ {
3452
+ const error = new Error ( 'foo' ) ;
3453
+ const error2 = new Error ( 'bar' ) ;
3454
+ error . stack = error2 ;
3455
+ error2 . stack = error ;
3456
+
3457
+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Error: bar\n [Circular *1]]]' ) ;
3458
+ }
0 commit comments