EndPointBlank.Management.Error exception (end_point_blank_elixir v0.12.0)

Copy Markdown View Source

A management API call that did not succeed (sc-1504).

Every EndPointBlank.Management call answers {:error, %Error{}} rather than raising; the stream/… functions raise it, since a stream cannot answer a tuple.

  • :code -- the API's stable error.code, a string, for programs to match on ("not_found", "validation_failed", "plan_limit", ...). A code this SDK does not know yet is kept as sent: see known_codes/0. The SDK adds four of its own, for answers that never reached the API or did not come back in its error shape: "transport_error", "unexpected_response", "invalid_request" and "not_available_for_managed_client".
  • :message -- for people; it may change.
  • :details -- field-level detail when the API sent any (for "validation_failed", the invalid fields), otherwise nil.
  • :status -- the HTTP status, or nil when no answer arrived.
  • :retry_after -- the Retry-After header in seconds, when sent.
  • :location -- the Location header, when sent. A credential POST refused with "idempotency_replay_unavailable" carries the credential's path here.

The management key is never part of an error, and neither is a request or response body other than the API's own error object.

case EndPointBlank.Management.Clients.get(mgmt, id) do
  {:ok, client} -> client
  {:error, %Error{code: "not_found"}} -> nil
  {:error, %Error{code: "rate_limited", retry_after: seconds}} -> ...
end

Summary

Functions

True when code is one the management API is documented to answer.

The error codes the management API is documented to answer, mapped to their HTTP status. A code missing from this map can still arrive and is surfaced unchanged; never treat an unknown code as a bug.

Types

t()

@type t() :: %EndPointBlank.Management.Error{
  __exception__: true,
  code: String.t(),
  details: term(),
  location: String.t() | nil,
  message: String.t(),
  retry_after: non_neg_integer() | nil,
  status: pos_integer() | nil
}

Functions

known_code?(code)

@spec known_code?(term()) :: boolean()

True when code is one the management API is documented to answer.

known_codes()

@spec known_codes() :: %{required(String.t()) => pos_integer()}

The error codes the management API is documented to answer, mapped to their HTTP status. A code missing from this map can still arrive and is surfaced unchanged; never treat an unknown code as a bug.