Libraries v5.0.0
    Preparing search index...

    Function withErrors

    • Wrap only a handler's invocation in an endpoint-checked error policy.

      Requires explicit .responses() declarations. Every possible translated status/body must fit the endpoint; file/raw/stream escape hatches are not accepted. Request and injected-service types are unchanged. Authentication, validation, middleware, DI and response serialization remain outside this wrapper and use the server's normal error handling.

      Type Parameters

      • E extends EndpointBuilder<any, any, any, any, any, any, any, any, any, any>

      Parameters

      • endpoint: E

        Configured HTTP endpoint, the sole source of handler types.

      • policy: keyof ResponsesOf<NoInfer<E>> extends never
            ? never
            : ErrorMap<
                ErrorResponsesOf<NoInfer<E>>,
                ResponseSignature<ErrorResponsesOf<NoInfer<E>>>,
            >

        Reusable policy compatible with the endpoint's responses.

      • handler: Handler<NoInfer<E>>

        Named or inline handler to wrap.

      Returns Handler<E>

      A handler suitable for handle, mapHandlers, or implementation scopes.