The errors of the Lettermint SDK.
Every error is an exception struct. Functions that call the API return
{:error, error}; iterate/3 streams and Lettermint.analytics_pages/3
raise the error instead. Configuration errors (Lettermint.ConfigError) are
always raised, because they are programming errors: a missing or
unrecognised token, an invalid option or an invalid ID.
| Error | When | Fields |
|---|---|---|
Lettermint.APIError | Any other 4xx with a JSON or empty body | status, code, message, details, body |
Lettermint.AuthenticationError | 401 | as APIError |
Lettermint.PermissionError | 403 | as APIError |
Lettermint.NotFoundError | 404 | as APIError |
Lettermint.ConflictError | 409 | as APIError |
Lettermint.ValidationError | 422 | as APIError, plus errors |
Lettermint.RateLimitError | 429 | as APIError, plus retry_after (seconds) |
Lettermint.ServerError | 5xx | as APIError, plus retry_after (seconds, when the API sent Retry-After) |
Lettermint.TimeoutError | No complete response within the timeout | timeout |
Lettermint.ConnectionError | The request failed (DNS, TLS, refused, reset) | reason |
Lettermint.UnexpectedResponseError | An empty or non-JSON body where JSON was expected, or an error page such as a proxy's HTML 502 | status, body_excerpt |
Lettermint.RedirectError | A 3xx response; redirects are never followed | status |
Lettermint.ConfigError | Raised: a missing or unrecognised token, an invalid option or ID | |
Lettermint.ClientValidationError | The SDK rejected the request before sending it, such as invalid tags | field |
Lettermint.WebhookVerificationError | A webhook delivery is not genuine | reason |
The guards in this module match the families:
import Lettermint.Error, only: [is_api_error: 1]
case Lettermint.Domains.retrieve(client, id) do
{:ok, domain} -> domain
{:error, %Lettermint.NotFoundError{}} -> nil
{:error, error} when is_api_error(error) -> handle(error.status, error.code)
{:error, error} -> raise error
endNo error contains request headers or API tokens.
Summary
Functions
The modules of the API errors (APIError and its per-status variants).
The modules of every SDK error.
True for Lettermint.APIError and its per-status variants.
True for any error of the SDK.
Types
@type t() :: Lettermint.APIError.t() | Lettermint.AuthenticationError.t() | Lettermint.PermissionError.t() | Lettermint.NotFoundError.t() | Lettermint.ConflictError.t() | Lettermint.ValidationError.t() | Lettermint.RateLimitError.t() | Lettermint.ServerError.t() | Lettermint.TimeoutError.t() | Lettermint.ConnectionError.t() | Lettermint.UnexpectedResponseError.t() | Lettermint.RedirectError.t() | Lettermint.ClientValidationError.t() | Lettermint.ConfigError.t() | Lettermint.WebhookVerificationError.t()
Any error of the SDK.
Functions
@spec api_errors() :: [module()]
The modules of the API errors (APIError and its per-status variants).
@spec errors() :: [module()]
The modules of every SDK error.
True for Lettermint.APIError and its per-status variants.
True for any error of the SDK.