oh-my-errors

1.0.5 • Public • Published

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!

Package Sidebar

Install

npm i oh-my-errors

Weekly Downloads

7

Version

1.0.5

License

none

Last publish

Collaborators

  • ferreiro