Check if a value is an error constructor
$ npm install --save is-error-constructor
const isErrorConstructor = require('is-error-constructor');
isErrorConstructor(Error);
//=> true
isErrorConstructor(RangeError);
//=> true
function FakeError() {}
isErrorConstructor(FakeError);
//=> false
class UnicornError extends Error {}
isErrorConstructor(UnicornError);
//=> true
MIT © Sindre Sorhus