Skip to content

dengyaolong/koa-error-catcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-error-catcher

Build Status NPM version npm download

A koa2 middleware to catch error and set response

Install

npm install koa-error-catcher --save

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"}

About

a middleware to catch error and set response

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published