mafintosh / Custom Error Class
Licence: mit
Straightforward ES6 class you can extend to make proper custom errors
Stars: ✭ 42
Programming Languages
javascript
184084 projects - #8 most used programming language
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
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].