koa-error-responder
v1.0.3
Published
Koa middleware for handling errors.
Downloads
3
Readme
Koa Error Responder
Koa middleware for handling errors thrown while handling a request.
Install
npm install koa-error-responder
Usage
import koaErrorResponder from 'koa-error-responder';
app.use(
koaErrorResponder({
debug: process.env.NODE_ENV !== 'production'
})
);
app.use(() => {
// This error will be handled by `koaErrorResponder`.
const error = new Error('Something went wrong');
error.statusCode = 403;
throw error;
});
Options
debug
- When enabled, internal server error messages will be included in responses. This should be turned off in production to avoid leaking server implementation details.