AggregateError.aggregateError
The AggregateError()
constructor creates an error for several errors that need to be wrapped in a single error.
Syntax
new AggregateError(errors[, message])
Parameters
errors
- An iterable of errors, may not actually be
Error
instances. -
message
Optional
- An optional human-readable description of the aggregate error.
Examples
Creating an AggregateError
try {
throw new AggregateError([
new Error("some error"),
], 'Hello');
} catch (e) {
console.log(e instanceof AggregateError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "AggregateError"
console.log(e.errors); // [ Error: "some error" ]
}
Specifications
|
Desktop |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
AggregateError() constructor |
85 |
No |
79 |
No |
No |
14 |
|
Mobile |
|
Android webview |
Chrome for Android |
Firefox for Android |
Opera for Android |
Safari on iOS |
Samsung Internet |
AggregateError() constructor |
85 |
85 |
No |
No |
14 |
No |
|
Server |
|
Node.js |
AggregateError() constructor |
No |
See also