The suppressed data property of a SuppressedError instance contains a reference to the original error that got suppressed because a new error was generated while handling it.
Value
Any value. Like Error/cause, you cannot assume it's an Error instance, although it usually is the case.
Examples
Using suppressed
try {
throw new SuppressedError(
new Error("New error"),
new Error("Original error"),
"Hello",
);
} catch (e) {
console.log(e.suppressed); // Error: "Original error"
}
Specifications
Browser compatibility
See also
- Polyfill of
SuppressedErrorincore-js - Control flow and error handling guide
- SuppressedError
Error:cause
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
