ExAtlas.Error exception (ExAtlas v0.5.0)

Copy Markdown View Source

Canonical error shapes returned by every ExAtlas.Provider callback.

Providers translate their native error bodies into one of these tagged tuples so callers can pattern-match once and handle errors from any provider.

Shapes

  • {:error, %ExAtlas.Error{kind: :unauthorized, ...}} — bad or missing API key.
  • {:error, %ExAtlas.Error{kind: :not_found, ...}} — resource doesn't exist.
  • {:error, %ExAtlas.Error{kind: :rate_limited, ...}} — provider 429.
  • {:error, %ExAtlas.Error{kind: :unsupported, ...}} — provider lacks this feature.
  • {:error, %ExAtlas.Error{kind: :provider, ...}} — provider-reported domain error.
  • {:error, %ExAtlas.Error{kind: :transport, ...}} — HTTP/socket failure.
  • {:error, %ExAtlas.Error{kind: :validation, ...}} — ExAtlas-side validation failure.

Summary

Functions

Translate an HTTP response ({status, body}) into an ExAtlas.Error.

Build an ExAtlas.Error from fields.

Types

kind()

@type kind() ::
  :unauthorized
  | :forbidden
  | :not_found
  | :rate_limited
  | :unsupported
  | :provider
  | :transport
  | :validation
  | :timeout
  | :unknown

t()

@type t() :: %ExAtlas.Error{
  __exception__: true,
  kind: kind(),
  message: String.t() | nil,
  provider: atom() | nil,
  raw: term(),
  status: integer() | nil
}

Functions

from_response(status, body, provider)

@spec from_response(integer(), term(), atom()) :: t()

Translate an HTTP response ({status, body}) into an ExAtlas.Error.

Used by every REST provider to normalize 4xx/5xx responses.

new(kind, opts \\ [])

@spec new(
  kind(),
  keyword()
) :: t()

Build an ExAtlas.Error from fields.