Beautiful error reporting for express
Beautiful, spec-compliant error reporting for express.
What does this do?
This express middleware simplifies debugging errors in express applications by presenting errors in a developer-friendly way.
Features:
- Beautiful HTML error reports thanks to youch
- Respects the
Accept
HTTP header - Hides sensitive information when running in production
- Compatible with other error middleware (custom error pages, custom error logging, ...)
Usage
npm install express-youch
const errorReporter = ; app;
Configuration options
links
Add custom links to the error report.
app.useerrorReporter;
Recepies
How do I customize the error pages?
When running in production (ie. when the NODE_ENV
environment variable is set to production
.), express-youch
will delegate HTML errors to the next error reporting middleware. Here is a basic example:
const errorReporter = ; // First, pass the errors to the error reporterapp; // Then add some custom handling logicapp;
The error object contains the properties statusCode
and message
, which you may use to create different error pages for different error types.
How to better manage my errors
You should us a combination of an asynchronous express router such as this one and the async/await syntax to make sure no errors leak outside of your control. Read this blog post to learn more about error handling in express.