Restify Errors Thrower
💥 Throw Restify errors easily and consistently!
$ npm install --save restify-errors-thrower
const restify = ;const thrower = ;// Creates a Restify serverconst server = restify;// Creates a foo endpointserver
throw(type, message, errno, [debug])
Throw a specific Restify error.
The type of error to throw. The list of types available can be found here
An human-friendly error message sent to the client.
Never sent error messages that comes from other modules!!! (E.g: your database)
This may expose you to undesired hackers attack!
Use the debug parameter instead for sensitive errors!
An unique error id code to send to clients.
This will help your client to programmatically handle the error your API will throw.
Choose a style and be consistent with it!
An indefinite number of contex information to collect.
This is particular useful to send contex details to your logger!
This will never sent to the client so you can store server critical messages. (E.g; errors coming from third pary APIs or errors coming from your DB)
Checks if a specific Restify error was thrown.
The object to check
The type of error that the object should be instance of.
- Simone Primarosa - simonepri
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.