Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sugarshin/micro-errors
A Error Handling for ZEIT's Micro
https://github.com/sugarshin/micro-errors
micro zeit
Last synced: 30 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T04:55:51.000Z (over 6 years ago)
- Last Synced: 2024-10-04T19:43:10.845Z (3 months ago)
- Topics: micro, zeit
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/micro-errors
- Size: 43 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# micro-errors
[![CircleCI](https://circleci.com/gh/sugarshin/micro-errors.svg?style=svg&circle-token=1c658fe9da795d5bd72050ca986a9370965bcc7b)](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