ozylog-http-errors

Create HTTP error objects


Keywords
ozylog, http, error, errors, nodejs
License
ICU
Install
npm install ozylog-http-errors@1.0.11

Documentation

http-errors

Create HTTP error objects

Travis npm

Installation

npm install @ozylog/http-errors --save

List of errors

new BadRequestError([message = 'Bad Request'])
new ForbiddenError([message = 'Forbidden'])
new InternalServerError([message = 'Internal Server Error'])
new NotAcceptableError([message = 'Not Acceptable'])
new NotFoundError([message = 'Not Found'])
new NotImplementedError([message = 'Not Implemented'])
new UnauthorizedError([message = 'Unauthorized'])
new CreateError([message], [statusCode])

Usage Example

import {BadRequestError} from '@ozylog/http-errors';

export function validate(req, res, next) {
  if (!req.body.name) return next(new BadRequestError());
}

License

MIT