AniLink - v3.0.0
    Preparing search index...

    Function sanitizeTokenError

    • Normalizes a failed OAuth token request into an AniLinkError subclass with a context-prefixed message.

      Token request bodies carry client_secret, authorization code, and refresh_token values, so the original Axios error is discarded: the returned error carries only a safe message (prefixed with label so logs identify the failing token exchange), a stable code, and, for HTTP failures, the upstream response body, which contains no credentials.

      Errors already normalized by the shared pipeline carry only safe fields (message, stable code, upstream response body), so they pass through with their specific classification intact; API failures are relabeled with the label prefix so logs still identify the failing token exchange. A new error is constructed for the relabel path (carrying the original as cause when the original carries no raw Axios error. A raw error on the cause chain would let cause-walking loggers reach the token grant's credentials) instead of mutating the existing instance's message in place, so consumers comparing messages across the same error instance are not surprised by mid-flight mutation.

      Parameters

      • error: unknown

        The value thrown by the token request transport.

      • label: string

        A context label prefixed to the safe message (for example "AniList token request" or "MAL token request").

      Returns AniLinkError

      A sanitized error that is safe to surface in application logs.