UnifiApi.TransportError exception (UnifiApi v0.4.0)

Copy Markdown View Source

Returned when the request never produced an HTTP response: connection refused, DNS failure, TLS handshake failure, timeout, and so on.

This wraps the underlying Req.TransportError / Req.HTTPError (or any other term the adapter surfaced) so that consumers can write one exhaustive case over UnifiApi.Error.t/0 without matching on Req's structs. The original is preserved in :original for debugging.

Example

case UnifiApi.Network.Sites.list(client) do
  {:ok, sites} -> handle(sites)
  {:error, %UnifiApi.TransportError{reason: :econnrefused}} -> :controller_down
  {:error, %UnifiApi.TransportError{reason: :timeout}} -> :slow
end

Summary

Types

t()

@type t() :: %UnifiApi.TransportError{
  __exception__: true,
  original: term(),
  reason: atom() | term()
}