# Error Handling and Consistent Error Responses

Express 5 passes an error from any route, async ones included, to error-handling middleware with four parameters, and a 404 handler after the routes catches every unknown path, so every error the API sends has one JSON shape and no caller ever sees an HTML page or a stack trace.

![Cheat sheet: Error Handling and Consistent Error Responses](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/3c19ef463a02470fb7241197261962f2.webp)

- Category: Node.js
- Level: Journeyman
- Tags: 404 Not Found, 500 Internal Server Error, Error-Handling Middleware, nodejs, Problem Details, rest-api, Stack Trace (javascript)
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/node-express-error-handling-cheat-sheet
