@@ -1287,8 +1287,14 @@ function identicalSequenceRange(a, b) {
1287
1287
return { len : 0 , offset : 0 } ;
1288
1288
}
1289
1289
1290
- function getStackString ( error ) {
1291
- return error . stack ? String ( error . stack ) : ErrorPrototypeToString ( error ) ;
1290
+ function getStackString ( ctx , error ) {
1291
+ if ( error . stack ) {
1292
+ if ( typeof error . stack === 'string' ) {
1293
+ return error . stack ;
1294
+ }
1295
+ return formatValue ( ctx , error . stack ) ;
1296
+ }
1297
+ return ErrorPrototypeToString ( error ) ;
1292
1298
}
1293
1299
1294
1300
function getStackFrames ( ctx , err , stack ) {
@@ -1303,7 +1309,7 @@ function getStackFrames(ctx, err, stack) {
1303
1309
1304
1310
// Remove stack frames identical to frames in cause.
1305
1311
if ( cause != null && isError ( cause ) ) {
1306
- const causeStack = getStackString ( cause ) ;
1312
+ const causeStack = getStackString ( ctx , cause ) ;
1307
1313
const causeStackStart = StringPrototypeIndexOf ( causeStack , '\n at' ) ;
1308
1314
if ( causeStackStart !== - 1 ) {
1309
1315
const causeFrames = StringPrototypeSplit ( StringPrototypeSlice ( causeStack , causeStackStart + 1 ) , '\n' ) ;
@@ -1324,6 +1330,7 @@ function improveStack(stack, constructor, name, tag) {
1324
1330
// for "regular errors" (errors that "look normal") for now.
1325
1331
let len = name . length ;
1326
1332
1333
+ console . error ( name , typeof name )
1327
1334
if ( typeof name !== 'string' ) {
1328
1335
stack = StringPrototypeReplace (
1329
1336
stack ,
@@ -1425,8 +1432,8 @@ function safeGetCWD() {
1425
1432
}
1426
1433
1427
1434
function formatError ( err , constructor , tag , ctx , keys ) {
1428
- const name = err . name != null ? err . name : 'Error' ;
1429
- let stack = getStackString ( err ) ;
1435
+ const name = err . name != null ? String ( err . name ) : 'Error' ;
1436
+ let stack = getStackString ( ctx , err ) ;
1430
1437
1431
1438
removeDuplicateErrorKeys ( ctx , keys , err , stack ) ;
1432
1439
0 commit comments