https://github.com/ozylog/http-errors
HTTP errors
https://github.com/ozylog/http-errors
errors http nodejs
Last synced: 6 months ago
JSON representation
HTTP errors
- Host: GitHub
- URL: https://github.com/ozylog/http-errors
- Owner: ozylog
- License: mit
- Archived: true
- Created: 2016-12-28T23:34:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-28T12:19:01.000Z (over 8 years ago)
- Last Synced: 2024-11-06T20:51:14.336Z (over 1 year ago)
- Topics: errors, http, nodejs
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-errors
Create HTTP error objects
[](https://travis-ci.org/ozylog/http-errors) [](https://www.npmjs.com/package/@ozylog/http-errors)
## Installation
```
npm install @ozylog/http-errors --save
```
## List of errors
```javascript
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
```javascript
import {BadRequestError} from '@ozylog/http-errors';
export function validate(req, res, next) {
if (!req.body.name) return next(new BadRequestError());
}
```
## License
MIT