@@ -1285,8 +1285,14 @@ function identicalSequenceRange(a, b) {
12851285 return { len : 0 , offset : 0 } ;
12861286}
12871287
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 ) ;
12901296}
12911297
12921298function getStackFrames ( ctx , err , stack ) {
@@ -1301,7 +1307,7 @@ function getStackFrames(ctx, err, stack) {
13011307
13021308 // Remove stack frames identical to frames in cause.
13031309 if ( cause != null && isError ( cause ) ) {
1304- const causeStack = getStackString ( cause ) ;
1310+ const causeStack = getStackString ( ctx , cause ) ;
13051311 const causeStackStart = StringPrototypeIndexOf ( causeStack , '\n at' ) ;
13061312 if ( causeStackStart !== - 1 ) {
13071313 const causeFrames = StringPrototypeSplit ( StringPrototypeSlice ( causeStack , causeStackStart + 1 ) , '\n' ) ;
@@ -1415,7 +1421,7 @@ function safeGetCWD() {
14151421
14161422function formatError ( err , constructor , tag , ctx , keys ) {
14171423 const name = err . name != null ? String ( err . name ) : 'Error' ;
1418- let stack = getStackString ( err ) ;
1424+ let stack = getStackString ( ctx , err ) ;
14191425
14201426 removeDuplicateErrorKeys ( ctx , keys , err , stack ) ;
14211427
0 commit comments