TypeSafe.Error exception (typesafe_ex v0.1.0)

Copy Markdown View Source

Why a call failed. Returned as {:error, %TypeSafe.Error{}}, raised by the bang functions.

reason is one of:

  • :no_api_key - no key was given and TYPESAFE_API_KEY is unset; no request was made
  • :bad_request (400), :authentication (401), :permission_denied (403), :not_found (404), :unprocessable_entity (422), :rate_limited (429), :overloaded (529), :server_error (other 5xx), :http_error (anything else)
  • :timeout, :connection - no HTTP response
  • :invalid_response - a 2xx whose body is missing a required field; message names the field

request_id is the x-typesafe-request-id header, when there was a response.

Summary

Types

reason()

@type reason() ::
  :no_api_key
  | :bad_request
  | :authentication
  | :permission_denied
  | :not_found
  | :unprocessable_entity
  | :rate_limited
  | :overloaded
  | :server_error
  | :http_error
  | :timeout
  | :connection
  | :invalid_response

t()

@type t() :: %TypeSafe.Error{
  __exception__: term(),
  body: term(),
  message: String.t(),
  reason: reason(),
  request_id: String.t() | nil,
  retry_after_ms: non_neg_integer() | nil,
  status: pos_integer() | nil
}