Lettermint.Error (Lettermint v2.0.0)

Copy Markdown View Source

The errors of the Lettermint SDK.

Every error is an exception struct. Functions that call the API return {:error, error}; iterate/3 streams 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.

ErrorWhenFields
Lettermint.APIErrorAny other 4xx with a JSON or empty bodystatus, code, message, details, body
Lettermint.AuthenticationError401as APIError
Lettermint.PermissionError403as APIError
Lettermint.NotFoundError404as APIError
Lettermint.ConflictError409as APIError
Lettermint.ValidationError422as APIError, plus errors
Lettermint.RateLimitError429as APIError, plus retry_after (seconds)
Lettermint.ServerError5xxas APIError
Lettermint.TimeoutErrorNo complete response within the timeouttimeout
Lettermint.ConnectionErrorThe request failed (DNS, TLS, refused, reset)reason
Lettermint.UnexpectedResponseErrorAn empty or non-JSON body where JSON was expected, or an error page such as a proxy's HTML 502status, body_excerpt
Lettermint.RedirectErrorA 3xx response; redirects are never followedstatus
Lettermint.ConfigErrorRaised: a missing or unrecognised token, an invalid option or ID
Lettermint.ClientValidationErrorThe SDK rejected the request before sending it, such as invalid tagsfield
Lettermint.WebhookVerificationErrorA webhook delivery is not genuinereason

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
end

No error contains request headers or API tokens.

Summary

Types

t()

Any error of the SDK.

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

Functions

api_errors()

@spec api_errors() :: [module()]

The modules of the API errors (APIError and its per-status variants).

errors()

@spec errors() :: [module()]

The modules of every SDK error.

is_api_error(term)

(macro)

True for Lettermint.APIError and its per-status variants.

is_lettermint_error(term)

(macro)

True for any error of the SDK.