UnifiApi.RateLimitError exception (UnifiApi v0.4.0)

Copy Markdown View Source

Returned when the controller responds with HTTP 429.

The :retry_after field is parsed from the Retry-After response header. Both seconds (integer) and HTTP-date forms are supported. Defaults to 60 seconds if absent or unparseable, and is clamped to the range 1..300.

The raw response :body is not stored — it can leak sensitive details via Inspect/Logger/Sentry. A scrubbed, truncated :body_preview (URL/host-like patterns redacted, ≤ 128 chars) is provided for diagnostics. See UnifiApi.Client.scrub_body_preview/1.

Example

case UnifiApi.Network.Clients.list(client, site_id) do
  {:ok, clients} ->
    handle(clients)

  {:error, %UnifiApi.RateLimitError{retry_after: seconds}} ->
    Process.sleep(seconds * 1000)
    retry()
end

Summary

Types

t()

@type t() :: %UnifiApi.RateLimitError{
  __exception__: true,
  body_preview: binary() | nil,
  retry_after: pos_integer(),
  status: 429
}