@dotcom-reliability-kit/middleware-render-error-info
Express middleware to render error information in a browser in a way that makes local debugging easier. This module is part of FT.com Reliability Kit.
Usage
Install @dotcom-reliability-kit/middleware-render-error-info
as a dependency:
npm install --save @dotcom-reliability-kit/middleware-render-error-info
Include in your code:
import renderErrorInfoPage from '@dotcom-reliability-kit/middleware-render-error-info';
const renderErrorInfoPage = require('@dotcom-reliability-kit/middleware-render-error-info');
renderErrorInfoPage
The renderErrorInfoPage
function can be used to generate Express middleware which renders an error debugging page. The error page will only ever display in a non-production environment, that is when the NODE_ENV
environment variable is either empty or set to "development"
.
It must be added to your Express app after all your application routes:
const app = express();
app.use(renderErrorInfoPage());
Note: if you're using @dotcom-reliability-kit/middleware-log-errors in your app, it's best to mount the error page middleware after the logging middleware. Otherwise the error will never be logged in local development, which may cause some confusion.
Once you've mounted the middleware, if you're working locally you should now see a detailed error page when you encounter an error in your app (assuming you're relying on the Express error handler to serve errors):
Contributing
See the central contributing guide for Reliability Kit.
License
Licensed under the MIT license.
Copyright © 2022, The Financial Times Ltd.