npm.io
1.0.2 • Published 3 years ago

koa-error-handler2

Licence
ISC
Version
1.0.2
Deps
0
Size
1 kB
Vulns
0
Weekly
0

koa-error-handler2

Error handler middleware for koa. Inspired by [koa-onerror] and [koa-error]

Install

npm i koa-error-handler2
Usage
koa-error-handler2(options)

Options:

  • template: {String} default template to render error to html, default ./error.html.
  • all: {Function} if options.all exist, ignore negotiation.
  • text: {Function} text error handler.
  • json: {Function} json error handler.
  • html: {Function} html error handler.
  • debug: {Boolean} whether to print error.stack in console.
  • alias: {Object} error.status alias.
Example
const koa = require('koa');
const app = koa();

const { errorHandler } = require('koa-error-handler2')

app.use(errorHandler);


app.listen(3000, function () {
  console.log('listening on port 3000.');
});
Test
test
License

MIT