Libraries v5.0.0
    Preparing search index...

    Class ErrorMap<R, Signature>

    Immutable, ordered exception translators. Create one with errorMap.

    Policies retain their exact response union until attached to an endpoint. They do not change that endpoint's responses, catch infrastructure errors, or automatically expose exception messages.

    Type Parameters

    • R extends ErrorResponse = never

      Union of all responses produced by this policy.

    • Signature = ResponseSignature<R>
    Index
    "[responseTypes]": Signature

    Retains status/body discrimination across exported policies.

    • Return a new policy with a translator appended. First matching rule wins. Put subclass rules before base-class rules. Translators may be async; translator failures propagate without re-entering this policy.

      Type Parameters

      Parameters

      • errorType: ErrorConstructor<E>

        Error constructor matched using instanceof.

      • translate: (error: E) => T | Promise<T>

        Application-owned conversion to an explicit response.

      Returns ErrorMap<R | T, Signature | ResponseSignature<T>>

    • Translate a recognized exception or rethrow the original value unchanged. Usually invoked by withErrors, not directly by an application.

      Parameters

      • error: unknown

      Returns Promise<R>