1.0.3 • Published 10 years ago

koa-error-callback v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

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