/node-http-errors

Easy to use, class-based http errors. Supports all http statuses.

Primary LanguageJavaScriptMIT LicenseMIT

Version License Dependencies

NodeJs HTTP Errors

Easy to use, class-based http errors. Supports all http statuses.

Install

yarn add @sadbox/node-http-errors

or

npm install -S @sadbox/node-http-errors

Usage

import { HttpError, BadRequest } from '@sadbox/node-http-errors';

let err = new HttpError({ status: 500, message: 'Internal Server Error.' });
err = new BadRequest(); // status 400 and default message for bad request error
err = new BadRequest('Bad User Input.'); // with custom message
err = new BadRequest({ fieldErrors }); // with custom property