AggregateError: errors

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

Thuộc tính dữ liệu errors của một instance AggregateError chứa một mảng đại diện cho các lỗi đã được tổng hợp.

Value

Một Array chứa các giá trị theo cùng thứ tự như iterable được truyền vào tham số đầu tiên của constructor AggregateError().

Property attributes of AggregateError: errors
Writableyes
Enumerableno
Configurableyes

Examples

Sử dụng errors

js
try {
  throw new AggregateError(
    // Một iterable chứa các lỗi
    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