SuppressedError: suppressed

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 suppressed của một instance SuppressedError chứa tham chiếu đến lỗi ban đầu bị che khuất vì một lỗi mới được tạo ra trong quá trình xử lý nó.

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: suppressed
Writableyes
Enumerableno
Configurableyes

Ví dụ

Sử dụng suppressed

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

Đặc tả

Specification
ECMAScript Async Explicit Resource Management
# sec-suppressederror

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

Xem thêm