Home

Awesome

is-typeof-error npmjs.com The MIT License

Check that given value is any type of error and instanceof Error.

code climate standard code style travis build status coverage status dependency status

Install

npm i is-typeof-error --save

Usage

For more use-cases see the tests

const isTypeofError = require('is-typeof-error')

isTypeofError

Check that val is error.

Params

Example

const isTypeofError = require('is-typeof-error')
const PluginError = require('plugin-error')
const KindError = require('kind-error')

const CustomClass = function () {}
CustomClass.prototype.foo = function () {}

isTypeofError(new TypeError('test'))           // => true
isTypeofError(new KindError('test'))           // => true
isTypeofError(new SyntaxError('test'))         // => true
isTypeofError(new PluginError('test', 'msg'))  // => true

isTypeofError(new CustomClass('test'))         // => false
isTypeofError(new Object({a: 'b'}))            // => false
isTypeofError(new RegExp('test'))              // => false
isTypeofError(Object.create({a: 'b'}))         // => false
isTypeofError(/regex/)                         // => false
isTypeofError({a: 'b'})                        // => false

Related

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github