The single failure value returned by every Auth0Client function.
Auth0 can fail in three unrelated ways — it answers with an error status, the request never reaches it, or no management token can be obtained — and all three arrive here as one struct, so a caller needs one clause rather than three:
case Auth0Client.Management.User.get(id) do
{:ok, user} -> user
{:error, %Auth0Client.Error{reason: :not_found}} -> nil
{:error, %Auth0Client.Error{} = error} -> raise error
endIt is an exception, so raise error works when a caller would rather not handle
the failure at all.
Summary
Functions
Builds an error for a failure that produced no HTTP response — a transport problem, or a management token that could not be obtained.
Builds an error from an HTTP response Auth0 rejected.
The Retry-After delay in seconds, or nil when the header is absent or is not
a plain number.
Types
Functions
Builds an error for a failure that produced no HTTP response — a transport problem, or a management token that could not be obtained.
@spec from_response(non_neg_integer(), term(), map()) :: t()
Builds an error from an HTTP response Auth0 rejected.
reason is derived from the status so callers can match on meaning rather than
on numbers.
@spec retry_after(t()) :: non_neg_integer() | nil
The Retry-After delay in seconds, or nil when the header is absent or is not
a plain number.
Auth0 sends this on a 429. Honour it rather than guessing a backoff:
{:error, %Auth0Client.Error{reason: :rate_limited} = error} ->
Process.sleep((Auth0Client.Error.retry_after(error) || 1) * 1000)The HTTP-date form of Retry-After is not parsed; Auth0 sends seconds.