util: add AggregateError.prototype.errors to inspect output

PR-URL: https://github.com/nodejs/node/pull/43646
Fixes: https://github.com/nodejs/node/issues/43645
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Livia Medeiros
2022-07-10 00:01:02 +08:00
committed by GitHub
parent 7cfd5f169c
commit 653cfff223
2 changed files with 29 additions and 1 deletions

View File

@@ -1352,6 +1352,12 @@ function formatError(err, constructor, tag, ctx, keys) {
keys.push('cause');
}
// Print errors aggregated into AggregateError
if (ArrayIsArray(err.errors) &&
(keys.length === 0 || !keys.includes('errors'))) {
keys.push('errors');
}
stack = improveStack(stack, constructor, name, tag);
// Ignore the error message if it's contained in the stack.

View File

@@ -9,7 +9,29 @@ AggregateError: original
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
code: 'ERR0'
code: 'ERR0',
[errors]: [
Error: original
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
code: 'ERR0'
},
Error: second error
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
code: 'ERR1'
}
]
}
Node.js *