Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

AggregateError

BaselineWidely available *

TheAggregateError 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 byPromise.any(), when all promises passed to it reject.

AggregateError is a subclass ofError.

Constructor

AggregateError()

Creates a newAggregateError object.

Instance properties

Also inherits instance properties from its parentError.

These properties are defined onAggregateError.prototype and shared by allAggregateError instances.

AggregateError.prototype.constructor

The constructor function that created the instance object. ForAggregateError instances, the initial value is theAggregateError constructor.

AggregateError.prototype.name

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

These properties are own properties of eachAggregateError instance.

errors

An array representing the errors that were aggregated.

Instance methods

Inherits instance methods from its parentError.

Examples

Catching an AggregateError

js
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" ]});

Creating an AggregateError

js
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
ECMAScript® 2026 Language Specification
# sec-aggregate-error-objects

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp