Error Handling Middleware
Express error middleware has four args: (err, req, res, next). Throw or next(err) from async handlers so one place formats errors.
- Do not leak stack traces in production.
- Log server-side; send safe messages to clients.
- Async routes need careful error forwarding.
console.log("error-handler");
After you read this chapter, use Write (when available) and Quiz on this page to lock it in.