https://github.com/sugarshin/micro-errors
  
  
    A Error Handling for ZEIT's Micro 
    https://github.com/sugarshin/micro-errors
  
micro zeit
        Last synced: 16 days ago 
        JSON representation
    
A Error Handling for ZEIT's Micro
- Host: GitHub
- URL: https://github.com/sugarshin/micro-errors
- Owner: sugarshin
- Created: 2018-08-13T09:31:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T04:55:51.000Z (about 7 years ago)
- Last Synced: 2025-10-11T10:23:06.356Z (20 days ago)
- Topics: micro, zeit
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/micro-errors
- Size: 43 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
 
Awesome Lists containing this project
README
          # micro-errors
[](https://circleci.com/gh/sugarshin/micro-errors)
[![npm version][npm-image]][npm-url]
A Error Handling for ZEIT's [Micro](https://github.com/zeit/micro).
```bash
yarn add micro-errors
```
## RFC7807
RFC7807 compliant ref: https://tools.ietf.org/html/rfc7807
## Usage
```js
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][license-url]
© sugarshin
[license-image]: https://img.shields.io/:license-mit-blue.svg?style=flat-square
[license-url]: https://sugarshin.mit-license.org/
[npm-image]: https://img.shields.io/npm/v/micro-errors.svg?style=flat-square
[npm-url]: https://www.npmjs.org/package/micro-errors