0.4.0 • Published 7 years ago
koa-http-errors v0.4.0
koa-http-errors
Error response formatter for koa.
Usage
var errors = require('koa-http-errors');
var app = new koa(); // koa-http-errors^0.4.0 for koa 2.x
app.use(errors());
Options
app.use(errors({
type: 'text/xml', // optional, to set the Content-type of the response
engine: 'ejs', // optional, any template engine, see https://www.npmjs.com/package/co-render
template: './error.ejs', // optional, template file path
cache: false, // optional, default is true
render: function *(content) {
// todo
// content.msg = error.message
// content.code = error.code
// content.env = process.env.NODE_ENV
// content.engine = options.engine
// content.template = options.template
// content.cache = options.cache
// content.ctx = ctx of koa
// content.err = err
} // optional, must be a generator function
}));