1.1.0-beta • Published 3 years ago

@bouncingpixel/http-errors v1.1.0-beta

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

http-errors

A set of Error classes which contain a status set for handling errors in Express.

Working With

Requirements

  • NodeJS 6 LTS

Using http-errors

The following Error classes exist with the status set:

ErrorStatus
BadRequestError400
NotAuthorizedError401
BannedError402
ForbiddenError403
NotFoundError404
AccountLockedError429
InternalServerError500

To raise one of these errors, first require in the @bouncingpixel/http-errors package, then just use like any other Error

  • call next, for example: next(new HttpErrors.BadRequestError('My Error Message'));
  • or throw the error, for example throw new HttpErrors.BadRequestError('My Error Message');
  • or use in a callback, for example done(new HttpErrors.BadRequestError('My Error Message'));
  • or any other use of an Error object