Socket
Socket
Sign inDemoInstall

create-http-error

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    create-http-error

Simply creates http ERRORs with the given http error code.


Version published
Maintainers
1
Install size
5.67 kB
Created

Readme

Source

create-http-error

Simply creates http ERRORs with the given http error code.

install

npm install --save create-http-error

use

var HttpError = require('create-http-error');

// e.g. as finalhandler after no route matched.
function finalhandler (req, res, next) {
    next(HttpError('400'));
}

app.use(finalhandler); // connect or express app.

api

HttpError(code [,message] [,properties])

creates an Error Object:

  • with the provided http error code like e.g. 500
  • if the message is omitted, the standard http error message is taken.
  • if a properties Object is provided, it's properties will be added to the Error Object.
HttpError.toString()

returns the String representation of the HttpError.

HttpError.toJSON()

returns the Javascript Object properties of the HttpError Object.

HttpError.codes

exposes the standard http error codes.

test

npm test

license

MIT

Keywords

FAQs

Last updated on 15 Jun 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc