oh-my-errors
v1.0.5
Published
Simple node module to handle multiple server-side errors with solution strategies
Downloads
5
Maintainers
Readme
Oh my errors!
Simple node module to handle multiple server-side errors with solution strategies.
How to use it
const errorHandler = require('oh-my-errors')
const error404 = errorHandler.createNotFoundError404({
origin: 'PLACE in your application where this error was originated',
message: 'Resource not found'
})
API methods
| Method | Parameters |
|----------|:-------------------:|
| createNotImplementedError501 | {String=} data.origin, {String=} data.message
|
| createBadRequest400 | {String=} data.origin, {String=} data.message
|
| createUnauthorizedError401 | {String=} data.origin, {String=} data.message
|
| createForbiddenError403 | {String=} data.origin, {String=} data.message
|
| createNotFoundError404 | {String=} data.origin, {String=} data.message
|
| createInternalError500 | {String=} data.origin, {String=} data.message
|
Possible errors
We support the most commun errors from HTTP Status codes
- 400 -> BadRequest (any params or whatever is bad)
- 401 -> UnauthorizedError (like 403, but in cases when you need to login)
- 404 -> NotFound (Resource not found. For example: user in the database, items, pages, etc...)
- 501 -> NotImplementedError
Contribute!
- Bugs, Pull Requests or feature requests? Go here! oh-my-errors Github repository
- Or... Send me an email jorge [AT] ferreiro [DOT] me