@rill/error
v1.3.3
Published
HttpError instance used in the Rill framework.
Downloads
206
Maintainers
Readme
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!