# dw-http-errors

> Collection of custom response errors and middleware for express

Latest version **1.0.0-beta.7** (published 2018-09-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install dw-http-errors
pnpm add dw-http-errors
yarn add dw-http-errors
bun add dw-http-errors
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.7 |
| Published | 2018-09-02 |
| First published | 2018-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.7.0 |
| Dependencies | 0 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Dwight Rodriques |
| Maintainers | drodriques |
| Keywords | http, express, status, code, error, response |

## Links

- npm: https://www.npmjs.com/package/dw-http-errors
- Repository: https://github.com/drodriques/dw-http-errors
- Homepage: https://github.com/drodriques/dw-http-errors#readme
- Issues: https://github.com/drodriques/dw-http-errors/issues
- npm.io page: https://npm.io/package/dw-http-errors

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.0-beta.7 (latest) — 2018-09-02
- 1.0.0-beta.6 — 2018-09-02
- 1.0.0-beta.5 — 2018-09-02
- 1.0.0-beta.4 — 2018-09-01
- 1.0.0-beta.3 — 2018-08-31
- 1.0.0-beta.2 — 2018-08-30
- 1.0.0-beta.1 — 2018-08-30
- 1.0.0-beta.0 — 2018-08-30

## README

# dw-http-errors [![NPM Version][npm-image]][npm-url]

> Collection of custom response errors and middleware for [express](https://expressjs.com).

## Install

```bash
npm i dw-http-errors -S
````

## Configure

Add middleware to your application bootstrap file:

```js
const { httpErrorsMiddleware } = require('dw-http-errors');

app.use(httpErrorsMiddleware);
```

## Usage

Throw generic HTTP exception

```js
const { HttpError } = require('dw-http-errors');

// Ex. with default status text
throw new HttpError(418);

// Ex. with custom message
throw new HttpError(418, 'I only brew tea');

```
Throw custom HTTP exception

```js
const { ImATeapotError } = require('dw-http-errors');

// Ex. with default status text
throw new ImATeapotError();

// Ex. with custom status text
throw new ImATeapotError('I only brew tea');
```

Exceptions thrown without a message defaults to HTTP standard status text.
Exceptions are handled by middle which relays errors as a HTTP response.

## Base Exception

- HttpError

## Custom Exceptions

  - BadRequestError
  - UnauthorizedError
  - PaymentRequiredError
  - ForbiddenError
  - NotFoundError
  - MethodNotAllowedError
  - NotAcceptableError
  - ProxyAuthenticationRequiredError
  - RequestTimeoutError
  - ConflictError
  - GoneError
  - LengthRequiredError
  - PreconditionFailedError
  - PayloadTooLargeError
  - URITooLongError
  - UnsupportedMediaTypeError
  - RangeNotSatisfiableError
  - ExpectationFailedError
  - ImATeapotError
  - MisdirectedRequestError
  - UnprocessableEntityError
  - LockedError
  - FailedDependencyError
  - UnorderedCollectionError
  - UpgradeRequiredError
  - PreconditionRequiredError
  - TooManyRequestsError
  - RequestHeaderFieldsTooLargeError
  - UnavailableForLegalReasonsError
  - InternalServerError
  - NotImplementedError
  - BadGatewayError
  - ServiceUnavailableError
  - GatewayTimeoutError
  - HttpVersionNotSupportedError
  - VariantAlsoNegotiatesError
  - InsufficientStorageError
  - LoopDetectedError
  - BandwidthLimitExceededError
  - NotExtendedError
  - NetworkAuthenticationRequiredError


## License

[MIT](LICENSE)

[npm-image]: https://img.shields.io/npm/v/dw-http-errors.svg
[npm-url]: https://www.npmjs.com/package/dw-http-errors

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