@@ -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 ;
@@ -3457,6 +3457,34 @@ ${error.stack.split('\n').slice(1).join('\n')}`,
3457
3457
3458
3458
assert . strictEqual (
3459
3459
inspect ( error ) ,
3460
- '[[\n Symbol(foo)\n]]'
3460
+ '[Error\n [\n Symbol(foo)\n ]]'
3461
3461
) ;
3462
3462
}
3463
+
3464
+ {
3465
+ const prepareStackTrace = Error . prepareStackTrace ;
3466
+
3467
+ Error . prepareStackTrace = ( error ) => error ;
3468
+
3469
+ const error = new Error ( 'foo' ) ;
3470
+
3471
+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3472
+
3473
+ Error . prepareStackTrace = prepareStackTrace ;
3474
+ }
3475
+
3476
+ {
3477
+ const error = new Error ( 'foo' ) ;
3478
+ error . stack = error ;
3479
+
3480
+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3481
+ }
3482
+
3483
+ {
3484
+ const error = new Error ( 'foo' ) ;
3485
+ const error2 = new Error ( 'bar' ) ;
3486
+ error . stack = error2 ;
3487
+ error2 . stack = error ;
3488
+
3489
+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Error: bar\n [Circular *1]]]' ) ;
3490
+ }
0 commit comments