AggregateError() constructor

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.
messageOptional
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

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
AggregateError() constructorChrome Full support 85Edge No support NoFirefox Full support 79IE No support NoOpera No support NoSafari Full support 14WebView Android Full support 85Chrome Android Full support 85Firefox Android No support NoOpera Android No support NoSafari iOS Full support 14Samsung Internet Android No support Nonodejs No support No

Legend

Full support
Full support
No support
No support

See also