Skip to content

Commit 36b9381

Browse files
committed
util: add AggregateError.prototype.errors to inspect output
1 parent b993789 commit 36b9381

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/internal/util/inspect.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,11 @@ function formatError(err, constructor, tag, ctx, keys) {
12941294
keys.push('cause');
12951295
}
12961296

1297+
// Print errors aggregated into AggregateError
1298+
if (err.errors && (keys.length === 0 || !keys.includes('errors'))) {
1299+
keys.push('errors');
1300+
}
1301+
12971302
stack = improveStack(stack, constructor, name, tag);
12981303

12991304
// Ignore the error message if it's contained in the stack.

test/message/error_aggregateTwoErrors.out

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,29 @@ AggregateError: original
99
at Module._load (node:internal/modules/cjs/loader:*:*)
1010
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
1111
at node:internal/main/run_main_module:*:* {
12-
code: 'ERR0'
12+
code: 'ERR0',
13+
[errors]: [
14+
Error: original
15+
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
16+
at Module._compile (node:internal/modules/cjs/loader:*:*)
17+
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
18+
at Module.load (node:internal/modules/cjs/loader:*:*)
19+
at Module._load (node:internal/modules/cjs/loader:*:*)
20+
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
21+
at node:internal/main/run_main_module:*:* {
22+
code: 'ERR0'
23+
},
24+
Error: second error
25+
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
26+
at Module._compile (node:internal/modules/cjs/loader:*:*)
27+
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
28+
at Module.load (node:internal/modules/cjs/loader:*:*)
29+
at Module._load (node:internal/modules/cjs/loader:*:*)
30+
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
31+
at node:internal/main/run_main_module:*:* {
32+
code: 'ERR1'
33+
}
34+
]
1335
}
1436

1537
Node.js *

0 commit comments

Comments
 (0)