Infusion.Runtime.Error exception (infusion_runtime v0.1.0)

Copy Markdown View Source

The error every SDK call returns as {:error, %Infusion.Runtime.Error{}}.

type tells what went wrong, so callers can match on it instead of on status codes:

typewhen
:bad_request400
:authentication401
:permission_denied403
:not_found404
:conflict409
:unprocessable_entity422
:rate_limit429, or any status with x-ratelimit-remaining: 0 (GitHub sends 403)
:internal_server500 and above
:api_errorany other status of 400 and above, or an error event in a stream
:timeoutno response in time
:connectionthe request could not be sent or the connection broke

For status errors, body is the decoded response body, headers the response headers and request_id the API's request ID, if it sent one (quote it when contacting the vendor's support). For :timeout and :connection, reason holds the underlying error.

Summary

Types

t()

@type t() :: %Infusion.Runtime.Error{
  __exception__: term(),
  body: term(),
  headers: %{optional(String.t()) => [String.t()]},
  message: String.t(),
  reason: term(),
  request_id: String.t() | nil,
  status: non_neg_integer() | nil,
  type: type()
}

type()

@type type() ::
  :bad_request
  | :authentication
  | :permission_denied
  | :not_found
  | :conflict
  | :unprocessable_entity
  | :rate_limit
  | :internal_server
  | :api_error
  | :timeout
  | :connection