This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.
* Some parts of this feature may have varying levels of support.
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.
AggregateError()Creates a new AggregateError object.
Also inherits instance properties from its parent Error.
These properties are defined on AggregateError.prototype and shared by all AggregateError instances.
AggregateError.prototype.constructorThe constructor function that created the instance object. For AggregateError instances, the initial value is the AggregateError constructor.
AggregateError.prototype.nameRepresents the name for the type of error. For AggregateError.prototype.name, the initial value is "AggregateError".
These properties are own properties of each AggregateError instance.
errorsAn array representing the errors that were aggregated.
Inherits instance methods from its parent Error.
Promise.any([Promise.reject(new Error("some error"))]).catch((e) => {
console.log(e instanceof AggregateError); // true
console.log(e.message); // "All Promises rejected"
console.log(e.name); // "AggregateError"
console.log(e.errors); // [ Error: "some error" ]
});
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" ]
}
| Desktop | Mobile | Server | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | Bun | Deno | Node.js | |
AggregateError |
85 | 85 | 79 | 71 | 14 | 85 | 79 | 60 | 14 | 14.0 | 85 | 14 | 1.0.0 | 1.2 | 15.0.0 |
AggregateError |
85 | 85 | 79 | 71 | 14 | 85 | 79 | 60 | 14 | 14.0 | 85 | 14 | 1.0.0 | 1.2 | 15.0.0 |
errors |
85 | 85 | 79 | 71 | 14 | 85 | 79 | 60 | 14 | 14.0 | 85 | 14 | 1.0.0 | 1.2 | 15.0.0 |
serializable_object |
98AggregateError serializes to the Error type, without additional properties. |
98AggregateError serializes to the Error type, without additional properties. |
103AggregateError serializes to the AggregateError type, with properties name, message, cause, and errors. |
84AggregateError serializes to the Error type, without additional properties. |
17 | 98AggregateError serializes to the Error type, without additional properties. |
103AggregateError serializes to the AggregateError type, with properties name, message, cause, and errors. |
68AggregateError serializes to the Error type, without additional properties. |
17 | 18.0AggregateError serializes to the Error type, without additional properties. |
98AggregateError serializes to the Error type, without additional properties. |
17 | ? | No | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError