loopback-common-errors

A few of common errors to use in loopback callbacks and next() functions

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
loopback-common-errors
100.0.47 years ago7 years agoMinified + gzip package size for loopback-common-errors in KB

Readme

loopback-common-errors

Little module for using the object Error as loopback uses them for returning error responses.
Example usage:
```sh var errors = require('loopback-common-errors'); ... if(user == null){
cb(errors.notFound('User Not Found'));
return;
} ... if(err){
cb(errors.serverError());
return;
} ```
You have 5 prototyped common functions:
  • badRequest(msg): returns status 400 and default message 'Bad Request'
  • fobidden(msg): returns status 403 and default message 'Forbidden'
  • notFound(msg): returns status 404 and default message 'Not Found'
  • serverError(msg): returns status 500 and default message 'Internal Server Error'
  • otherError(name, msg, status): returns an Error with fields passed as args