ExTypesafe.Error (ExTypesafe v0.2.0)

Copy Markdown View Source

Represents an error returned by the TypeSafe API or the client itself.

Fields

  • :status — HTTP status code (e.g. 401, 422, 429, 529), :transport for network-level errors before a response is received, :validation for a request rejected locally before it is sent, or :invalid_response when a successful HTTP response has an unexpected body.
  • :message — Human-readable description of the error.
  • :body — Raw response body (if available), useful for inspecting validation details.
  • :request_id — The TypeSafe request ID from x-typesafe-request-id, if the server sent one.

Common status codes

StatusMeaning
401Missing or invalid API key.
422Request body failed validation (missing field, malformed question, etc).
429Rate limit exceeded. Retried automatically with exponential backoff.
529TypeSafe temporarily overloaded. Retried automatically.

Summary

Types

status()

@type status() :: pos_integer() | :transport | :validation | :invalid_response

t()

@type t() :: %ExTypesafe.Error{
  body: term() | nil,
  message: String.t(),
  request_id: String.t() | nil,
  status: status()
}