Home

Awesome

koa-onerror

NPM version build status Test coverage David deps Known Vulnerabilities npm download

an error handler for koa, hack ctx.onerror.

different with koa-error:

install

npm install koa-onerror

Usage

const fs = require('fs');
const koa = require('koa');
const onerror = require('koa-onerror');

const app = new koa();

onerror(app);

app.use(ctx => {
  // foo();
  ctx.body = fs.createReadStream('not exist');
});

Options

onerror(app, options);

check out default handler to write your own handler.

Status and Headers

koa-onerror will automatic set err.status as response status code, and err.headers as response headers.

License

MIT

Contributors