custom-error-class

1.0.0 • Public • Published

custom-error-class

Straightforward ES6 class you can extend to make custom errors that are all instanceof Error with proper stacks.

npm install custom-error-class

Usage

const CustomError = require('custom-error-class')
 
class MyError extends CustomError {
  constructor () {
    super('an error happened')
    this.code = 'SOME_CODE'
  }
}
 
// Use this error as you normally would.
throw new MyError()

Credits to @pfrazee who wrote most of it.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i custom-error-class

Weekly Downloads

139

Version

1.0.0

License

MIT

Unpacked Size

3.26 kB

Total Files

5

Last publish

Collaborators

  • mafintosh