Exception structs used by the SDK.
Every SDK failure surfaces as one of these structs. Functions that can fail return them in an
{:error, exception} tuple, and the ! variants raise them. All the HTTP-level exceptions
(TypeSafe.APIError and its siblings) share the same fields — :status, :body, :headers,
:request_id, :endpoint and :message — so a single rescue/pattern can inspect any of them.
Categories
TypeSafe.ConfigError— invalid configuration or input discovered before a request is sent (missing API key, empty questions, an unserializable body).TypeSafe.ConnectionError— the request never produced an HTTP response.TypeSafe.TimeoutError— the request exceeded its configured timeout (aConnectionError).TypeSafe.ResponseValidationError— a 2xx response whose body did not match the schema.TypeSafe.APIErrorand the per-status structs below — the server returned an error status.
Status mapping
Summary
Functions
Build the exception struct that matches an HTTP error status.
Extract a human-readable message from a decoded error body, mirroring the shapes the API uses.
Types
@type t() :: TypeSafe.ConfigError.t() | TypeSafe.ConnectionError.t() | TypeSafe.TimeoutError.t() | TypeSafe.ResponseValidationError.t() | TypeSafe.APIError.t()
Any exception struct the SDK may raise or return.
Functions
@spec api_error( pos_integer(), term(), %{optional(String.t()) => String.t()}, String.t() | nil ) :: TypeSafe.APIError.t()
Build the exception struct that matches an HTTP error status.
headers is a map of lowercased header names to string values. endpoint is a human-readable
"METHOD URL" (without credentials) or nil.
Extract a human-readable message from a decoded error body, mirroring the shapes the API uses.
Returns nil when no message can be found.