koa-err

1.0.1 • Public • Published

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

/koa-err/

    Package Sidebar

    Install

    npm i koa-err

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • ivpusic