AttractorEx.LLM.Error exception (attractor_phoenix v0.1.0)

Copy Markdown View Source

Typed error returned by unified LLM adapters and client retries.

The struct normalizes provider/API/transport failures into a consistent shape so callers can make retry, logging, and host-event decisions without pattern matching on provider-specific payloads.

Summary

Types

error_type()

@type error_type() ::
  :transport
  | :timeout
  | :rate_limited
  | :authentication
  | :permission
  | :invalid_request
  | :server
  | :api
  | :unsupported
  | :unknown

t()

@type t() :: %AttractorEx.LLM.Error{
  __exception__: true,
  code: String.t() | nil,
  details: map(),
  message: String.t(),
  provider: String.t() | nil,
  raw: term(),
  retry_after_ms: non_neg_integer() | nil,
  retryable: boolean(),
  status: pos_integer() | nil,
  type: error_type()
}

Functions

from_http_response(provider, status, body, headers \\ %{})

@spec from_http_response(String.t() | nil, pos_integer(), term(), map()) :: t()

new(attrs \\ [])

@spec new(keyword()) :: t()

normalize(error, opts)

@spec normalize(
  term(),
  keyword()
) :: t()

retryable?(arg1)

@spec retryable?(term()) :: boolean()

transport(provider, reason)

@spec transport(String.t() | nil, term()) :: t()