https://github.com/tilap/error-extend
Node js custom error class builder
https://github.com/tilap/error-extend
Last synced: over 1 year ago
JSON representation
Node js custom error class builder
- Host: GitHub
- URL: https://github.com/tilap/error-extend
- Owner: tilap
- License: mit
- Created: 2016-04-25T10:54:12.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-25T11:22:38.000Z (about 10 years ago)
- Last Synced: 2025-03-05T19:07:30.108Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Error extend [![NPM version][npm-image]][npm-url]
============================
Simple way to extend JS Error class with custom code or default message.
## Install
```
npm install --save error-extend
```
## Usage
```
const errorExtends = require('error-extend');
const MyCustomError = errorExtends({ name: 'MyCustomError', code: 418, defaultMessage: 'I am a teapot' });
throw new MyCustomError();
throw new MyCustomError('I am a wonderfull teapot');
```
## Options
- ```name```, the name of the error class
- ```code```, default code of the error
- ```defaultMessage```, default message of the error is none is provided on Error instance
- ```init```: an init function with error to custom on settings
## License
MIT
[npm-image]: https://img.shields.io/npm/v/error-extend.svg?style=flat
[npm-url]: https://npmjs.org/package/error-extend