SuppressedError: error

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Thuộc tính dữ liệu error của một instance SuppressedError chứa tham chiếu đến lỗi gây ra việc bị che khuất (suppression).

Giá trị

Bất kỳ giá trị nào. Giống như cause, bạn không thể giả định đây là một instance Error, mặc dù thường thì đó là trường hợp.

Property attributes of SuppressedError: error
Writableyes
Enumerableno
Configurableyes

Ví dụ

Sử dụng error

js
try {
  throw new SuppressedError(
    new Error("New error"),
    new Error("Original error"),
    "Hello",
  );
} catch (e) {
  console.log(e.error); // Error: "New error"
}

Đặc tả

Specification
ECMAScript Async Explicit Resource Management
# sec-suppressederror

Tương thích trình duyệt

Xem thêm