Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nswbmw/koa-errorhandler
Error handler middleware for koa.
https://github.com/nswbmw/koa-errorhandler
Last synced: 2 months ago
JSON representation
Error handler middleware for koa.
- Host: GitHub
- URL: https://github.com/nswbmw/koa-errorhandler
- Owner: nswbmw
- Created: 2015-03-16T05:38:43.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T15:52:53.000Z (almost 5 years ago)
- Last Synced: 2024-11-08T07:50:56.709Z (2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-star - koa-errorhandler
- awesome-koa - koa-errorhandler - Koa 的错误处理程序中间件。 ![](https://img.shields.io/github/stars/nswbmw/koa-errorhandler.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/koa-errorhandler.svg?style=flat-square) (仓库 / 中间件)
README
## koa-errorhandler
Error handler middleware for koa. Inspired by [koa-onerror](https://github.com/koajs/onerror) and [koa-error](https://github.com/koajs/error).
### Install
```
npm i koa-errorhandler --save
```### Usage
```
errorHandler(options)
```Options:
- template: {String} default template to render error to html, default `./error.html`.
- all: {Function} if options.all exist, ignore negotiation.
- text: {Function} text error handler.
- json: {Function} json error handler.
- html: {Function} html error handler.
- debug: {Boolean} whether to print error.stack in console.
- alias: {Object} error.status alias.### Example
```
var koa = require('koa');
var errorHandler = require('./')var app = koa();
app.use(errorHandler());
app.use(function* () {
foo();
});app.listen(3000, function () {
console.log('listening on port 3000.');
});
```### Test
```
npm test
```### License
MIT