@@ -1285,8 +1285,14 @@ function identicalSequenceRange(a, b) {
1285
1285
return { len : 0 , offset : 0 } ;
1286
1286
}
1287
1287
1288
- function getStackString ( error ) {
1289
- return error . stack ? String ( error . stack ) : ErrorPrototypeToString ( error ) ;
1288
+ function getStackString ( ctx , error ) {
1289
+ if ( error . stack ) {
1290
+ if ( ArrayIsArray ( error . stack ) ) {
1291
+ return formatArray ( ctx , error . stack ) ;
1292
+ }
1293
+ return String ( error . stack ) ;
1294
+ }
1295
+ return ErrorPrototypeToString ( error ) ;
1290
1296
}
1291
1297
1292
1298
function getStackFrames ( ctx , err , stack ) {
@@ -1301,7 +1307,7 @@ function getStackFrames(ctx, err, stack) {
1301
1307
1302
1308
// Remove stack frames identical to frames in cause.
1303
1309
if ( cause != null && isError ( cause ) ) {
1304
- const causeStack = getStackString ( cause ) ;
1310
+ const causeStack = getStackString ( ctx , cause ) ;
1305
1311
const causeStackStart = StringPrototypeIndexOf ( causeStack , '\n at' ) ;
1306
1312
if ( causeStackStart !== - 1 ) {
1307
1313
const causeFrames = StringPrototypeSplit ( StringPrototypeSlice ( causeStack , causeStackStart + 1 ) , '\n' ) ;
@@ -1415,7 +1421,7 @@ function safeGetCWD() {
1415
1421
1416
1422
function formatError ( err , constructor , tag , ctx , keys ) {
1417
1423
const name = err . name != null ? String ( err . name ) : 'Error' ;
1418
- let stack = getStackString ( err ) ;
1424
+ let stack = getStackString ( ctx , err ) ;
1419
1425
1420
1426
removeDuplicateErrorKeys ( ctx , keys , err , stack ) ;
1421
1427
0 commit comments