
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
@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 196 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 5 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.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.