koa-err
v1.0.1
Published
Error handling middleware for koa
Downloads
7
Readme
koa-err
Error handling middleware for koa
Installation
npm install koa-err
Example
var koa = require('koa'),
route = require('koa-route'),
fs = require('co-fs'),
koaErr = require('koa-err'),
app = koa(),
app.use(koaErr());
app.use(route.get('/first', function * (next) {
// some unhlandled generator error...
var dummy = yield fs.readdir('someunknown');
yield next;
}));
You will receive error with err.status
or default 500
, and err.message
or default err
.
You can also define your own custom global error handler:
app.use(koaErr(function (err) {
// some custom global handler logic...
}));
License
MIT