koa-handle-error
v0.0.5
Published
Error handler Middleware for [email protected]
Downloads
35
Readme
koa-handle-error
Error handler Middleware for [email protected]
Installation
npm install koa-handle-error
Usage
IMPORTANT: handleError
must register first as Koa middleware!
const Koa = require('koa');
const handleError = require('koa-handle-error');
const app = new Koa();
const onError = err => {
console.error(err);
};
app.use(handleError(onError)); // must register first!
app.use(someMiddleware());
app.use(otherMiddleware());
API
handleError(onError: Function): (context: Koa.Context, next: () => Promise) => void
Returns a Koa middleware.
onError
will called with the error when some error occured.