Skip to content

sindresorhus/is-error-constructor

Repository files navigation

is-error-constructor

Check if a value is an error constructor

Install

$ npm install is-error-constructor

Usage

import isErrorConstructor from 'is-error-constructor';

isErrorConstructor(Error);
//=> true

isErrorConstructor(RangeError);
//=> true

function FakeError() {}
isErrorConstructor(FakeError);
//=> false

class UnicornError extends Error {}
isErrorConstructor(UnicornError);
//=> true

Related

  • is - Type check values

About

Check if a value is an error constructor

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •