npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dotcom-reliability-kit/middleware-render-error-info

v5.1.1

Published

Express middleware to render error information in a way that makes local debugging easier and production error rendering more consistent.

Downloads

749

Readme

@dotcom-reliability-kit/middleware-render-error-info

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.

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';
// 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):

Reliability Kit Error Info Page

Debug headers

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.

Migrating

Consult the Migration Guide if you're trying to migrate to a later major version of this package.

Contributing

See the central contributing guide for Reliability Kit.

License

Licensed under the MIT license. Copyright © 2022, The Financial Times Ltd.