D-ID Client SDK - v3.0.0-0
    Preparing search index...

    Class HttpError

    A request to the Agents API came back with a non-2xx status.

    Raised for every REST call the SDK makes on the application's behalf: fetching the agent in createAgentManager, creating the stream and the chat during connect(), sending a message with chat(), and the rating and feedback calls. The same error is both handed to onError and thrown, so it also rejects the promise of whichever method made the request — catch it around that call, or handle it centrally in the callback. For the message-send request behind chat() the callback may not fire; the error is still thrown. Typical cases are 401 or 403 for a client key that is not authorized for the agent or the calling domain, and 404 for an unknown agent id; an account that is out of credits comes back with code 'InsufficientCreditsError'. A 429 is retried twice, one second apart (three attempts in total), before it surfaces.

    kind is always 'HttpError', so a switch on it narrows a caught value to this class. The server's own classification lives on code — the 'InsufficientCreditsError' above is one — so a message-independent branch on a specific API failure is possible.

    The message is the envelope's description when the body is that JSON, and the raw body otherwise — truncated to 256 characters either way, because a gateway can answer a 5xx with a whole HTML page.

    Hierarchy (View Summary)

    Index
    code: string

    The Agents API's own classification of the failure — the kind from D-ID's { kind, description } error body — and 'HttpError' when the response was not that envelope.

    An account out of credits comes back as 'InsufficientCreditsError', for instance. It is a plain string because the set is the API's, not the SDK's, and grows without an SDK release. Use status for the transport-level branch, this for the API-level one, and kind to tell an HttpError from the SDK's other errors.

    endpoint?: string

    Path of the request that failed, relative to the API client's base path — for example /agt_x/chat/cht_y for a message sent to a chat.

    Absent when the error was constructed without call context. NetworkError.endpoint is the same value on a transport failure.

    kind: "HttpError" = 'HttpError'

    Always 'HttpError'. Branch on it to tell this failure from the other SDK errors.

    method?: string

    HTTP method of the request that failed, such as GET or POST.

    Absent when the error was constructed without call context.

    originalError?: unknown

    The error or value that caused this one, when the SDK was wrapping something else.

    For a NetworkError this is the browser's own fetch rejection. It is not serialized as-is: toJson() takes only an Error cause's message.

    status: number

    HTTP status code of the response, such as 401, 404 or 500.