🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

statuserror

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statuserror

Error object with a status code

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
2
Created
Source

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() {
    //
  })

Keywords

error

FAQs

Package last updated on 05 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts