LlmCall.Error (llm_call v0.1.0)

Copy Markdown View Source

A codec error.

retryable? is a hint derived from the provider's error code, not a retry policy. kind says who produced the error: a codec produces :validation, :invalid_response or :provider; the client adds :transport for a failure that never reached a provider.

retry_after_ms is the parsed Retry-After header, when the transport saw one; it is a hint, not a retry policy.

raw is the provider payload the error was decoded from, and it follows LlmCall.Config.capture_raw like every other raw: it is nil unless the policy is :response or :all.

code is the provider's machine-readable code as a string (OpenAI's code, Anthropic's error type, Google's status such as "RESOURCE_EXHAUSTED", MiniMax's numeric code stringified). status is the HTTP status, and only the client sets it: a codec never sees the response status, so it always leaves it nil.

reason is the structured counterpart of a :transport message, and only the client sets it. Match on it instead of the message. The library produces:

  • {:unknown_pool, name} — the configured Finch pool is not running;
  • :exception — the HTTP transport raised;
  • :disconnected — the Responses WebSocket is not connected;
  • {:interrupted, why} — an in-flight WebSocket lane was dropped (:reconnected, :max_age, {:unroutable_event, :stream_id_not_echoed}, or the close reason);
  • {:connection_exited, why} — the WebSocket connection process ended;
  • the transport's own reason otherwise (:econnrefused, :timeout, :closed, :nxdomain, {:tls_alert, ...}).

A codec leaves it nil, and so does any failure that has a status.

Summary

Types

A structured transport reason, or nil when the failure has none.

t()

Types

reason()

@type reason() :: atom() | tuple() | nil

A structured transport reason, or nil when the failure has none.

An atom or a tuple; the module documentation lists the values this library produces and the transport reasons it passes through. Only kind: :transport sets it.

t()

@type t() :: %LlmCall.Error{
  code: String.t() | nil,
  kind: :validation | :invalid_response | :provider | :transport,
  message: String.t(),
  raw: map() | nil,
  reason: reason(),
  retry_after_ms: non_neg_integer() | nil,
  retryable?: boolean(),
  status: non_neg_integer() | nil
}