@rill/error
TypeScript icon, indicating that this package has built-in type declarations

1.3.3 • Public • Published

Rill
@rill/error
API Stability TypeScript Styled with prettier Build status Test Coverage NPM Version Downloads Browser Bundle Size

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

Installation

npm install @rill/error

Example

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!

Package Sidebar

Install

npm i @rill/error

Weekly Downloads

28

Version

1.3.3

License

MIT

Last publish

Collaborators

  • dylanpiercey