Skip to content

mariusc23/micro-error-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

micro-error-handler

Error handler middleware for micro.

Installation

npm install --save @mariusc23/micro-error-handler

Usage

const { applyMiddleware } = require('@mariusc23/micro-middleware')
const { errorHandler } = require('@mariusc23/micro-error-handler')

module.exports = applyMiddleware([errorHandler], async (req, res) => {
  return 'Hello world'
})

Example Response

{
  "error": {
    "code": 500,
    "message": "Unknown Error"
  }
}

License

Copyright (c) 2017 Marius Craciunoiu. Licensed under the MIT license.