# immutable-app-http-error

> Immutable app http error

Latest version **0.1.19** (published 2018-11-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install immutable-app-http-error
pnpm add immutable-app-http-error
yarn add immutable-app-http-error
bun add immutable-app-http-error
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.19 |
| Published | 2018-11-17 |
| First published | 2017-03-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.6.0 |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ersun Warncke |
| Maintainers | ersun.warncke |

## Links

- npm: https://www.npmjs.com/package/immutable-app-http-error
- Repository: https://github.com/warncke/immutable-app-http-error
- Homepage: https://github.com/warncke/immutable-app-http-error#readme
- Issues: https://github.com/warncke/immutable-app-http-error/issues
- npm.io page: https://npm.io/package/immutable-app-http-error

## Recent versions

- 0.1.19 (latest) — 2018-11-17
- 0.1.18 — 2018-01-15
- 0.1.17 — 2017-10-06
- 0.1.16 — 2017-10-04
- 0.1.15 — 2017-09-19
- 0.1.14 — 2017-09-10
- 0.1.13 — 2017-09-04
- 0.1.12 — 2017-08-05
- 0.1.11 — 2017-08-02
- 0.1.10 — 2017-07-27
- 0.1.9 — 2017-06-07
- 0.1.8 — 2017-06-06
- 0.1.7 — 2017-06-03
- 0.1.6 — 2017-06-02
- 0.1.5 — 2017-05-30
- … 5 more at https://npm.io/package/immutable-app-http-error/versions

## README

# immutable-app-http-error

Throws an error object that will be used by the
[immutable-app](https://www.npmjs.com/package/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 Code  | Default Message       |
------------|-----------------------|
400         | Application Error     |
403         | Access Denied         |
404         | Not Found             |
409         | Conflict              |
500         | Internal 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.

---
_Source: https://npm.io/package/immutable-app-http-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
