A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError below:

AggregateError - JavaScript | MDN

AggregateError

Baseline Widely available *

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.

Constructor
AggregateError()

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.

AggregateError.prototype.constructor

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

AggregateError.prototype.name

Represents 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.

errors

An array representing the errors that were aggregated.

Instance methods

Inherits instance methods from its parent Error.

Examples Catching an AggregateError
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
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 Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3