The AggregateError object represents an error when several errors need to be wrapped in a single error. It is thrown when multiple errors need to be reported by an operation, for example by Promise.any(), when all promises passed to it reject.

AggregateError is a subclass of Error.



Creates a new AggregateError object.

Instance properties

Also inherits instance properties from its parent Error.

These properties are defined on AggregateError.prototype and shared by all AggregateError instances.


The constructor function that created the instance object. For AggregateError instances, the initial value is the AggregateError constructor.

Represents the name for the type of error. For, the initial value is "AggregateError".

These properties are own properties of each AggregateError instance.


An array that essentially reflects the iterable with which the AggregateError was instantiated; for example, if the AggregateError was created using the AggregateError() constructor, an array produced from whatever iterable was passed to the constructor as its first argument.

Instance methods

Inherits instance methods from its parent Error.


Catching an AggregateError

  Promise.reject(new Error("some error")),
]).catch((e) => {
  console.log(e instanceof AggregateError); // true
  console.log(e.message);                   // "All Promises rejected"
  console.log(;                      // "AggregateError"
  console.log(e.errors);                    // [ Error: "some error" ]

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(;                      // "AggregateError"
  console.log(e.errors);                    // [ Error: "some error" ]


ECMAScript Language Specification
# sec-aggregate-error-objects

Browser compatibility

BCD tables only load in the browser

See also