1.0.2 • Published 1 year ago

koa-error-handler2 v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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