Skip to content

rill-js/error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

💥 The http error function used in Rill.

Resources

Stars

Watchers

Forks

Packages

No packages published