5.1.0 • Published 11 days ago

@dotcom-reliability-kit/middleware-render-error-info v5.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

@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.

5.1.0

11 days ago

5.0.6

18 days ago

5.0.5

2 months ago

5.0.4

3 months ago

5.0.3

4 months ago

5.0.2

4 months ago

5.0.1

4 months ago

5.0.0

4 months ago

4.1.1

5 months ago

4.1.0

5 months ago

3.0.4

6 months ago

3.0.3

7 months ago

3.0.2

8 months ago

3.1.0

6 months ago

3.0.1

9 months ago

3.0.0

9 months ago

4.0.1

6 months ago

4.0.0

6 months ago

4.0.2

6 months ago

2.1.1

11 months ago

1.1.16

1 year ago

1.1.15

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

1.1.14

1 year ago

2.0.0

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.13

1 year ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.12

1 year ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago