Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@dotcom-reliability-kit/middleware-render-error-info
Advanced tools
Express middleware to render error information in a way that makes local debugging easier and production error rendering more consistent.
Express middleware to render error information in a browser in a way that makes local debugging easier and production error rendering more consistent. This module is part of FT.com Reliability Kit.
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';
// or
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 in local development and a sensible stripped-back error page in production.
When the NODE_ENV
environment variable is either empty or set to "development"
then a full debug page will be rendered. Otherwise only the error status code and message will be output, e.g. 500 Server Error
. This ensures that we don't leak important error information in production.
[!CAUTION]
This middleware must be added to your Express app after all your application routes – you won't get rendered errors for any routes which are mounted after this middleware.
const app = express();
// App routes go here
app.use(renderErrorInfoPage());
[!CAUTION]
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.
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):
As well as rendering an error page, the middleware also sends an error-fingerprint
HTTP header in the response. This contains the error fingerprint and is available in development and production. Inspecting this header on a generic error page can help identify the root cause of an issue.
Consult the Migration Guide if you're trying to migrate to a later major version of this package.
See the central contributing guide for Reliability Kit.
Licensed under the MIT license.
Copyright © 2022, The Financial Times Ltd.
FAQs
Express middleware to render error information in a way that makes local debugging easier and production error rendering more consistent.
The npm package @dotcom-reliability-kit/middleware-render-error-info receives a total of 299 weekly downloads. As such, @dotcom-reliability-kit/middleware-render-error-info popularity was classified as not popular.
We found that @dotcom-reliability-kit/middleware-render-error-info demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.