Server - Technical Reference - v26.4.1
    Preparing search index...
    • Global Error Handling Middleware for Express.

      This middleware intercepts all errors passed via next(err). It performs three critical functions:

      1. Normalization: Converts native JS Errors into standardized ApiError objects.
      2. Security: Strips sensitive stack traces in production environments.
      3. Observability: Populates res.locals for centralized logging (e.g., Pino/Winston).

      Parameters

      • err: ApiError | Error

        The error object (could be a custom ApiError or a native Error).

      • _req: Request
      • res: Response

        The Express Response object.

      • _next: NextFunction

      Returns void