@tadashi/koa-error
v10.0.0
Published
Middleware for Koa.js
Downloads
18
Readme
koa-error
A Koa error handler
middleware
Install
$ npm i @tadashi/koa-error
Usage
import Koa from 'koa'
import error from '@tadashi/koa-error'
const koa = new Koa()
koa
.use(error(true))
.use(ctx => {
ctx.throw(401)
})
.on('error', error => {
console.error(error.message) // Unauthorized
})
API
error(emit)
| parameter | type | required | default | description | | --------- | ------- | -------- | ------- | ---------------- | | emit | boolean | no | false | Emit error event |
License
MIT © Thiago Lagden