A Error Handling for ZEIT's Micro
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
.eslintrc
.gitignore
.node-version
README.md
index.js
package.json
test.js
yarn.lock

README.md

micro-errors

CircleCI npm version

A Error Handling for ZEIT's Micro.

yarn add micro-errors

RFC7807

RFC7807 compliant ref: https://tools.ietf.org/html/rfc7807

Usage

const { handleErrors, createError } = require('micro-errors')

module.exports = handleErrors({ debug: true })(async (req, res) => {
  throw createError(400, 'Bad Request')
})

// HTTP/1.1 400 Bad Request
// Content-Type: application/problem+json
//
// {
//   "type": "about:blank",
//   "title": "Bad Request",
//   "status": 400,
//   "instance": "/foo/bar",
// }

License

MIT

© sugarshin