error-express-handler
This package exports a middleware for express that handles Error and HttpError(custom package type).
Install
npm install --save @map-colonies/error-express-handler
API documentation
Check the autogenerated documentation here.
Usage
Add the handler as the last middleware, so any error forwarded by the controllers will be handled.
If the value of NODE_ENV
is production the error message will be redacted and a generic one will be sent instead.
In development, in addition to the error message, the stack trace of the error will be included in the response.
import express from 'express';
import { getErrorHandlerMiddleware } from '@map-colonies/error-express-handler';
process.env.NODE_ENV = 'development';
const app = express();
app.use('/meow', fn);
app.use(getErrorHandlerMiddleware());
app.listen(8080, function() {
console.log('server is up');
});
Flow
note
This page was generated from a remote source. you can find it on https://github.com/MapColonies/error-express-handler/blob/master/README.md