This class contains a set of predefined error objects which are thought to be used in your API route callbacks. (Barefoot.APIAdapter)
Each of these errors contain a proper HTTP status code which will be delivered to the requesting client in case of an error.
If you’d like to create your own error, you can use the createError function to simplify the process.
How to create a new error
var errors = require('barefoot').errors;
var MyError = errors.createError(500, 'MyError');
throw new MyError('Something went terribly wrong :(');
How to use builtin errors
var errors = require('barefoot').errors;
throw new errors.NotFoundError('Contact not found!');
Summary
Barefoot.Errors | This class contains a set of predefined error objects which are thought to be used in your API route callbacks. |
Functions | |
createError | Creates an Error with a specified HTTP status code and name. |
Errors | |
NotFoundError | If any resource was not found, this is the generic error for that situation. |