@sadbox/node-http-errors
v1.2.0
Published
HTTP errors
Downloads
4
Readme
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({ code: 500, message: 'Internal Server Error.' });
err = new BadRequest(); // code 400 and default message for bad request error
err = new BadRequest('Bad User Input.'); // with custom message
err = new BadRequest({ fieldErrors }); // with custom property