v133 · 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

    Robust cross-realm Error check.

  2. Cross-realm check

    The proposal's motivating case: an iframe's Error object fails instanceof Error in the parent. A table runs both checks against same-realm, cross-realm, Proxy-wrapped and plain values.

  3. Promise rejection router

    An unhandledrejection classifier that picks the right log level — promote real Error/DOMException, warn duck-typed objects, debug primitives. The pattern instanceof Error can't power.

  4. Error type matrix

    Runs all four detection approaches — Error.isError(), instanceof Error, duck typing (.message), and Object.prototype.toString — across 15 value types (native errors, DOMException, AggregateError, Proxy-wrapped, plain objects, primitives). Highlights where each approach fails and where Error.isError() wins.

  5. Async error classifier

    Seven runnable async scenarios — native errors, DOMExceptions, string rejections, plain objects, AggregateError, Proxy-wrapped errors, and a chained multi-step pipeline. The live log shows exactly what Error.isError() returns at each catch site and why it beats instanceof for mixed-type promise rejection handling.

why it shipped

See https://github.com/tc39/proposal-is-error/blob/main/README.md

references