A structured error returned by MoneyHub functions.
Every public function in this library that can fail returns
{:error, %MoneyHub.Error{}} (or raises a MoneyHub.Error from the !
variants) rather than ad-hoc tuples, so callers can pattern match on
reason regardless of where in the stack the failure occurred.
Reasons
:config_error- theMoneyHub.Configpassed in was invalid.:network_error- the HTTP transport failed (DNS, TLS, connect timeout, connection reset, etc).causeholds the underlying exception orMint/Fincherror term.:api_error- the API responded with a non-2xx status.statusandbodyare populated;codeis the Moneyhub-specific error code from the response body when present (e.g."INVALID_REQUEST").:rate_limited- the API responded429.retry_after(integer seconds) is populated when theRetry-Afterheader was present.:decode_error- the response body could not be parsed as JSON or did not match the expected shape.:jwt_error- signing or verifying a JWT (client assertion, id_token, webhook payload) failed.causeholds the underlying reason.:validation_error- a function argument failed local validation before any request was made (for example an invalid claims map).
Summary
Types
@type reason() ::
:config_error
| :network_error
| :api_error
| :rate_limited
| :decode_error
| :jwt_error
| :validation_error
@type t() :: %MoneyHub.Error{ __exception__: true, body: term(), cause: term(), code: String.t() | nil, message: String.t(), reason: reason(), retry_after: non_neg_integer() | nil, status: pos_integer() | nil }