Favorites

JavaScript AggregateError Object

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
AggregateError
JavaScript Errors · ConstructorThis object is supported by all modern browsers.
Updated 28th November 2026

An AggregateError wraps several errors in one. It is thrown by Promise.any() when every promise rejects, with the individual errors in its errors property.

Description

An AggregateError represents several errors at once. Its errors property is an array of the individual errors. JavaScript throws one from Promise.any() when all of the promises passed to it reject, since there is no single reason to report. You can create your own to report several validation problems together.

You can create your own with new AggregateError(errors, message), which is handy when validating a form or a batch of items and you want to report every problem at once rather than stopping at the first. The errors property holds whatever you passed in, normally an array of Error objects, and the usual message and name properties describe the group as a whole.

AggregateError is a subclass of Error, so err instanceof Error is true, and the optional cause option works as it does for other errors. When logging, loop over errors to show each individual message, since most consoles only show the top-level message by default.

Creating

new AggregateError(errors, message)

Example

Promise.any([
  Promise.reject(new Error('Server A down')),
  Promise.reject(new Error('Server B down')),
]).catch(err => {
  console.log(err.name);
  console.log(err.errors.map(e => e.message));
});

Browser Support

The following information will show you the current browser support for the AggregateError object. Hover over a browser icon to see the version that first introduced support for this object.

This object is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee