Error.isError()
Error.isError() provides a reliable way to test whether a value is an Error instance. It is useful when instanceof checks become fragile across realms or execution contexts.
Overview
Error.isError() provides a reliable way to test whether a value is an Error instance. It is useful when instanceof checks become fragile across realms or execution contexts.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 134 | 134 | 138 | 18.4 | 134 | 18.4 | |
- This browser only partially implements this feature
- Returns `false` for `DOMException` instances.
- This browser only partially implements this feature
- Returns `false` for `DOMException` instances.
Syntax
Error.isError(new Error('test')); // true
Error.isError(new TypeError()); // true
Error.isError({ message: 'fake' }); // false Live demo
Check native Error objects
Use Error.isError when available, otherwise fall back to instanceof Error.
Inspect different thrown values
Compare errors, strings, and plain objects with the same helper.
Use inside catch handling
Normalize catch blocks that may receive non-Error values.
Use cases
Shared error pipelines
Normalize error handling in utilities that may receive thrown values from different execution contexts.
Runtime guards
Distinguish real Error objects from arbitrary thrown values before formatting or reporting them.
Cautions
- A reliable error check still does not guarantee the value contains the information your UI needs.
- Thrown strings and custom objects remain possible, so keep fallback handling in place.
Accessibility
- Reliable error detection helps ensure users receive consistent failure messages and recovery options.
- Error handling only improves accessibility if the resulting UI feedback is perceivable and actionable.
Related links
Powered by web-features