Error.isError

Specification
Proposal repo

Modules

es.error.is-error.

Built-ins signatures

class Error {
  static isError(value: any): boolean;
}

Entry points

core-js/proposals/is-error
core-js(-pure)/es|stable|actual|full/error/is-error

Examples

Error.isError(new Error('error')); // => true
Error.isError(new TypeError('error')); // => true
Error.isError(new DOMException('error')); // => true

Error.isError(null); // => false
Error.isError({}); // => false
Error.isError(Object.create(Error.prototype)); // => false

Warning

We have no bulletproof way to polyfill this Error.isError / check if the object is an error, so it's a rather naive implementation.