ReqAnthropic.Error exception (ReqAnthropic v0.2.1)

Copy Markdown View Source

Normalized error returned by ReqAnthropic when the Anthropic API responds with a non-2xx status, or when the client itself fails before sending.

Summary

Functions

Build an Error from a Req response. The Anthropic API returns errors as %{"type" => "error", "error" => %{"type" => ..., "message" => ...}}.

Build an Error from a Req response with a pre-parsed %RateLimit{}.

Types

t()

@type t() :: %ReqAnthropic.Error{
  __exception__: term(),
  message: String.t() | nil,
  rate_limit: ReqAnthropic.RateLimit.t() | nil,
  raw: term(),
  request_id: String.t() | nil,
  status: pos_integer() | nil,
  type: String.t() | nil
}

Functions

from_response(response)

@spec from_response(Req.Response.t()) :: t()

Build an Error from a Req response. The Anthropic API returns errors as %{"type" => "error", "error" => %{"type" => ..., "message" => ...}}.

from_response(response, rate_limit)

@spec from_response(Req.Response.t(), ReqAnthropic.RateLimit.t()) :: t()

Build an Error from a Req response with a pre-parsed %RateLimit{}.