statuserror

0.1.3 • Public • Published

statuserror

An error with a status code.

Usage

Install:

npm i statuserror --save

Use:

var StatusError = require('statuserror');
 
// Without a message...
var e = new StatusError(404);
// e.status == 404
// e.message = "Not Found"
 
// With a message...
var e = new StatusError(500, "Something has gone horribly wrong");
// e.status == 500
// e.message = "Something has gone horribly wrong"
 
// With `throw`...
function doSomething(value) {
  if (!value) throw new StatusError(400, 'Value expected');
  // ...
}
 
// With Bluebird...
new Promise(function(resolve, reject) {
    reject(new StatusError(500));
  })
  .catch(StatusError, function() {
    //
  })

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.3
    74
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.3
    74
  • 0.1.2
    2
  • 0.1.1
    1
  • 0.0.1
    2

Package Sidebar

Install

npm i statuserror

Weekly Downloads

8

Version

0.1.3

License

MIT

Last publish

Collaborators

  • suprememoocow
  • andrewnewdigate