ke

koa-exception

Exception Handler Middleware Base on Koa@2.x

Showing:

Popularity

Downloads/wk

14

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

1

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

koa-exception

It's a koa middleware. Dependency on koa@2.

Chinese Simplified

Why

When i use koa to dev my project that find everytime i have to handler exception at the route.

For example, a method maybe throws MongoError or other errors called by route,so you always must handler it.

However, that's a not good way to do bussiness.

Use koa-exception, what you need do is that focus on your bussiness.

Install

npm install koa-exception --save

Usage

app.js

var app = require('koa')();
var KoaEx = require('koa-exception');

/** NOTE:
KoaEx must be used first before any other middleware, and then 
it will catch all of the exception throwed by route,dao and os.
*/       
app.use(KoaEx());

var port = 3000;
app.listen(port, function() {
  console.log('Server running on port ' + port);
});

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100