0.1.19 • Published 5 years ago

immutable-app-http-error v0.1.19

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

immutable-app-http-error

Throws an error object that will be used by the immutable-app framework to generate the appropriate HTTP response.

Throwing a supported error with default message

const httpError = require('immutable-app-http-error')

httpError(404)

Supported error codes and default messages

Error CodeDefault Message
400Application Error
403Access Denied
404Not Found
409Conflict
500Internal Server Error

httpError arguments

httpError(code, message, data, cookies, headers)

Throwing an error with a custom message

httpError(123, 'FOOBAR')

Throwing an error with data attached

httpError(409, null, {...})

Any error can have data attached. In the case of 409 Conflict errors the data will be returned as the response body along with the 409 status code.

Throwing an error that sets cookies with response

httpError(400, null, null, {foo: bar})

The cookies aregument must be an object. Each property will be used as the cookie name and the value will be used to set/clear the cookie.

If the value is false the cookie is cleared.

If the value is a string the cookie will be set with default options.

If the value is an object the value property of the object will be used as the cookie value and the rest of the properties will be used to set the cookie options.

Throwing an error that sets http headers with response

httpError(400, null, null, null, {foo: bar})

The headers argument must be an object. The properties and values will be used to set http headers for the response.

0.1.19

5 years ago

0.1.18

6 years ago

0.1.17

7 years ago

0.1.16

7 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago