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
Specification |
---|
Promise.any The definition of 'AggregateError()' in that specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AggregateError() constructor | Chrome Full support 85 | Edge No support No | Firefox Full support 79 | IE No support No | Opera No support No | Safari Full support 14 | WebView Android Full support 85 | Chrome Android Full support 85 | Firefox Android No support No | Opera Android No support No | Safari iOS Full support 14 | Samsung Internet Android No support No | nodejs No support No |
Legend
- Full support
- Full support
- No support
- No support