http-errors-lite
Create HTTP errors for Express, Koa, Connect, etc. with ease. This is a drop-in replacement for the normal http-errors
only with zero dependancies and 50% less memory usage (give or take).
Install
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install http-errors-lite
Example
var createError = var express = var app = app
API
This is the current API, currently extracted from Koa and subject to change.
Error Properties
expose
- can be used to signal ifmessage
should be sent to the client, defaulting tofalse
whenstatus
>= 500headers
- can be an object of header names to values to be sent to the client, defaulting toundefined
. When defined, the key names should all be lower-casedmessage
- the traditional error message, which should be kept short and all single linestatus
- the status code of the error, mirroringstatusCode
for general compatibilitystatusCode
- the status code of the error, defaulting to500
createError([status], [message], [properties])
Create a new error object with the given message msg
.
The error object inherits from createError.HttpError
.
var err =
status: 500
- the status code as a numbermessage
- the message of the error, defaulting to node's text for that status code.properties
- custom properties to attach to the object
createError([status], [error], [properties])
Extend the given error
object with createError.HttpError
properties. This will not alter the inheritance of the given
error
object, and the modified error
object is the
return value.
fs
status
- the status code as a numbererror
- the error object to extendproperties
- custom properties to attach to the object