Setu-TS
    Preparing search index...

    Function errorHandler

    • Creates a global error-handler middleware.

      Behavior:

      1. Calls next() inside a try/catch.
      2. If next() throws an HttpError, its statusCode is used as-is.
      3. If next() throws any other Error, it is wrapped in a 500 internalServerError carrying the original as cause.
      4. When configured, lets the application write its own response. A returned or resolved HandlerResult short-circuits formatting; undefined falls through.
      5. When logErrors is on and a logger is registered, the unmasked error is logged with the status the selected response serves.
      6. Otherwise, formats the error via selectFormatter, optionally enriches it with a stack trace, and sends it with the right status and content type. The middleware returns a HandlerResult (short-circuit) and never re-invokes next().

      Parameters

      Returns MiddlewareFunction

      A middleware function

      0.1.0