# @rill/error

> HttpError instance used in the Rill framework.

Latest version **1.3.3** (published 2017-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rill/error
pnpm add @rill/error
yarn add @rill/error
bun add @rill/error
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2017-11-11 |
| First published | 2015-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dylan Piercey |
| Maintainers | dylanpiercey |
| Keywords | error, errors, http error, isomorphic, rill, universal |

## Links

- npm: https://www.npmjs.com/package/@rill/error
- Repository: https://github.com/rill-js/error
- Issues: https://github.com/rill-js/error/issues
- npm.io page: https://npm.io/package/@rill/error

## 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.3.3 (latest) — 2017-11-11
- 1.3.2 — 2017-10-22
- 1.3.1 — 2017-10-16
- 1.3.0 — 2017-10-16
- 1.2.0 — 2016-09-28
- 1.1.0 — 2016-09-27
- 1.0.1 — 2016-08-25
- 1.0.0 — 2016-08-25
- 0.1.1 — 2015-12-18
- 0.1.0 — 2015-10-13

## README

<h1 align="center">
  <!-- Logo -->
  <img src="https://raw.githubusercontent.com/rill-js/rill/master/Rill-Icon.jpg" alt="Rill"/>
  <br/>
  @rill/error
	<br/>

  <!-- Stability -->
  <a href="https://nodejs.org/api/documentation.html#documentation_stability_index">
    <img src="https://img.shields.io/badge/stability-stable-brightgreen.svg" alt="API Stability"/>
  </a>
  <!-- TypeScript -->
  <a href="http://typescriptlang.org">
    <img src="https://img.shields.io/badge/%3C%2F%3E-typescript-blue.svg" alt="TypeScript"/>
  </a>
  <!-- Prettier -->
  <a href="https://github.com/prettier/prettier">
    <img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="Styled with prettier"/>
  </a>
  <!-- Travis build -->
  <a href="https://travis-ci.org/rill-js/@rill/error">
  <img src="https://img.shields.io/travis/rill-js/@rill/error.svg" alt="Build status"/>
  </a>
  <!-- Coveralls coverage -->
  <a href="https://coveralls.io/github/rill-js/@rill/error">
    <img src="https://img.shields.io/coveralls/rill-js/@rill/error.svg" alt="Test Coverage"/>
  </a>
  <!-- NPM version -->
  <a href="https://npmjs.org/package/@rill/error">
    <img src="https://img.shields.io/npm/v/@rill/error.svg" alt="NPM Version"/>
  </a>
  <!-- Downloads -->
  <a href="https://npmjs.org/package/@rill/error">
    <img src="https://img.shields.io/npm/dm/@rill/error.svg" alt="Downloads"/>
  </a>
  <!-- Size -->
  <a href="https://npmjs.org/package/@rill/error">
    <img src="https://img.shields.io/badge/size-766b-green.svg" alt="Browser Bundle Size"/>
  </a>
</h1>

This module is used internally by Rill but is extracted for convenience.
Utility for generating HttpError's with messages, codes and meta data.

# Installation

```console
npm install @rill/error
```

# Example
```javascript
import HttpError, { assert, fail } from "@rill/error";

new HttpError(404); //-> [HttpError Not Found]

fail(404); //-> throws [HttpError Not Found]

assert(false, 404); //-> throws [HttpError Not Found]
assert(true, 404); //-> Does nothing
```

# API
+ **HttpError(statusCode, [statusMessage], [metaData])** : Creates a new HttpError.
+ **HttpError.fail(statusCode, [statusMessage], [metaData])** : Creates a new HttpError and automatically throws it.
+ **HttpError.assert(value, statusCode, [statusMessage], [metaData])** : Creates a new HttpError and automatically throws it if value is falsey.

### Contributions

Use `npm test` to run tests.
Please feel free to create a PR!

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