Error handler Middleware for [email protected]
npm install koa-handle-error
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());
Returns a Koa middleware.
onError
will called with the error when some error occured.