restify-errors-options
🔧 Add custom options to Restify's errors!
DEPRECATED!!!
Install
$ npm install --save restify-errors-options
Usage
const errorsOptions = ;// Is extremely important to require restify-errors-options before restify.const errors = ; // Default behaviourconst err1 = errno: 'NFE';console;//=> {code: 'NotFound', message: ''} // Add errno as option to add to the bodyerrorsOptions;const err2 = errno: 'NFE';console;//=> {code: 'NotFound', message: '', errno: 'NFE'}console;//=> {code: 'NotFound', message: ''} // Restore the default behaviourerrorsOptions;const err3 = errno: 'NFE';console;//=> {code: 'NotFound', message: ''}console;//=> {code: 'NotFound', message: '', errno: 'NFE'}console;//=> {code: 'NotFound', message: ''}
Plugins
Community packages that implement adds options through this package. If you want yours listed here open a PR.
- restify-errors-options-errno: Add errno to Restify's errors
API
add(optName, [optDefault])
Adds custom options to errors' body.
optName
Type: string
Name of the option key to add.
optDefault
Type: (number|boolean|string|object)
Default value for the option. You can also provide a function, see the next section.
optDefault(errorCode, errorHttpCode, errorMessage)
Type: function
Returns the default value for the option using parameters of the error.
delete(optName)
Removes previously added custom options..
optName
Type: string
Name of the option key to remove.
Authors
- Simone Primarosa - simonepri
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.