An Exact Online API or transport failure.
Every Exact function returns {:error, %Exact.Error{}} instead of raising,
except for the bang variants. Match on :reason rather than on :status so
transport failures are covered too.
| reason | when |
|---|---|
:validation | 400, the request or payload was rejected |
:unauthorized | 401, the token is missing, expired or revoked |
:forbidden | 403, the token lacks the scope or division access |
:not_found | 404 |
:rate_limited | 429, check :rate_limit and :retry_after |
:server_error | 5xx |
:http_error | any other non-2xx status |
:transport | the request never got a response |
Summary
Functions
Builds an error from a transport level exception.
Builds an error from a non-2xx Req.Response.
Types
@type reason() ::
:validation
| :unauthorized
| :forbidden
| :not_found
| :rate_limited
| :server_error
| :http_error
| :transport
@type t() :: %Exact.Error{ __exception__: true, body: term(), code: String.t() | nil, message: String.t(), rate_limit: Exact.RateLimit.t() | nil, reason: reason(), retry_after: integer() | nil, status: pos_integer() | nil }
Functions
@spec from_exception(Exception.t()) :: t()
Builds an error from a transport level exception.
@spec from_response(Req.Response.t()) :: t()
Builds an error from a non-2xx Req.Response.