GenAgent.Backend.Error (GenAgent v0.8.0)

Copy Markdown View Source

A backend-independent failure returned by the bundled backend adapters.

:kind is a coarse classifier suitable for application retry policies; :retryable? indicates that another attempt may succeed. A retry is never performed automatically. :retry_after preserves the HTTP Retry-After header value (seconds or an HTTP date) when the provider supplies one. :raw retains the original provider value for provider-specific handling. Neither :message nor :raw should be logged without considering secrets.

Summary

Functions

Build an error from a non-2xx HTTP response.

Build a non-HTTP provider or transport error without guessing retryability.

Normalize a provider failure while keeping its original value in :raw.

Types

t()

@type t() :: %GenAgent.Backend.Error{
  kind: atom(),
  message: String.t() | nil,
  provider: :claude | :codex | :anthropic | :openai,
  raw: term(),
  retry_after: String.t() | nil,
  retryable?: boolean(),
  status: non_neg_integer() | nil
}

Functions

http(provider, status, body, headers \\ %{}, raw \\ nil)

@spec http(atom(), non_neg_integer(), term(), map() | list(), term()) :: t()

Build an error from a non-2xx HTTP response.

new(provider, kind, raw, opts \\ [])

@spec new(atom(), atom(), term(), keyword()) :: t()

Build a non-HTTP provider or transport error without guessing retryability.

normalize(provider, error)

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

Normalize a provider failure while keeping its original value in :raw.