Global Error Handling Middleware for Express.
This middleware intercepts all errors passed via next(err). It performs three critical functions:
next(err)
res.locals
The error object (could be a custom ApiError or a native Error).
The Express Response object.
Global Error Handling Middleware for Express.
This middleware intercepts all errors passed via
next(err). It performs three critical functions:res.localsfor centralized logging (e.g., Pino/Winston).