1.0.4 • Published 7 years ago

koa-error-catcher v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

koa-error-catcher

a koa2 middleware to catch error and set response

Install

npm install koa-error-catcher

Usage

const Koa = require('koa');
const app = new Koa();
const errorCatcher = require('koa-error-catcher');

// error catcher 
app.use(errorCatcher);

app.use(ctx => {
    ctx.throw('throw an error')
    ctx.body = {ok: 1}
});

app.listen(3030);

//  curl -v 127.0.0.1:3030
//  response 500 & body is {"message":"throw an error"}
1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago