loopback-common-errors

0.0.4 • Public • Published

loopback-common-errors

Little module for using the object Error as loopback uses them for returning error responses.

Example usage:

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

Readme

Keywords

Package Sidebar

Install

npm i loopback-common-errors

Weekly Downloads

235

Version

0.0.4

License

ISC

Last publish

Collaborators

  • demakrated