v134 · javascript
Error.isError
Adds the Error.isError(obj) static method. It returns true for JS native errors and DOMExceptions, and false otherwise.
concepts
-
Error.isError
Error.isError() — the missing first-class check, works across realms where instanceof Error fails.
-
Cross-realm error check
The TC39 motivating case: errors from an iframe, a structured-clone round-trip, or a DOMException. Side-by-side scoreboard of
instanceof ErrorvsError.isErrorfor each. -
Test Suite
16 pathological inputs (iframe error, worker, fake with toStringTag, AggregateError, SuppressedError…) against Error.isError vs three legacy checks. Run, scoreboard.
-
Error Boundary Builder
Design a multi-layer error boundary: each layer gates on Error.isError, then routes by type. Configure the thrown value (Error, DOMException, string, null, fake) and trace which layer handles it.
why it shipped
See https://github.com/tc39/proposal-is-error/blob/main/README.md