v134 · javascript

Error.isError

Adds the Error.isError(obj) static method. It returns true for JS native errors and DOMExceptions, and false otherwise.

concepts

  1. Error.isError

    Error.isError() — the missing first-class check, works across realms where instanceof Error fails.

  2. 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 Error vs Error.isError for each.

  3. Test Suite

    16 pathological inputs (iframe error, worker, fake with toStringTag, AggregateError, SuppressedError…) against Error.isError vs three legacy checks. Run, scoreboard.

  4. 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

references