v133 · 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
Robust cross-realm Error check.
-
Cross-realm check
The proposal's motivating case: an iframe's
Errorobject failsinstanceof Errorin the parent. A table runs both checks against same-realm, cross-realm, Proxy-wrapped and plain values. -
Promise rejection router
An
unhandledrejectionclassifier that picks the right log level — promote realError/DOMException, warn duck-typed objects, debug primitives. The patterninstanceof Errorcan't power. -
Error type matrix
Runs all four detection approaches —
Error.isError(),instanceof Error, duck typing (.message), andObject.prototype.toString— across 15 value types (native errors, DOMException, AggregateError, Proxy-wrapped, plain objects, primitives). Highlights where each approach fails and whereError.isError()wins. -
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 beatsinstanceoffor mixed-type promise rejection handling.
why it shipped
See https://github.com/tc39/proposal-is-error/blob/main/README.md