AggregateError: errors - JavaScript | MDN

Value

An Array containing values in the same order as the iterable passed as the first argument of the AggregateError() constructor.

Property attributes of AggregateError: errors
Writableyes
Enumerableno
Configurableyes

Examples

Using errors

js

try {
  throw new AggregateError(
    // An iterable of errors
    new Set([new Error("some error"), new Error("another error")]),
    "Multiple errors thrown",
  );
} catch (err) {
  console.log(err.errors);
  // [
  //   Error: some error,
  //   Error: another error
  // ]
}

Specifications

Specification
ECMAScript® 2027 Language Specification
# sec-aggregate-error

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.