Demografix.Error exception (Demografix v0.1.0)

Copy Markdown View Source

The error returned or raised by every Demografix call.

A single struct carries the typed :kind, the HTTP :status, the server :message, and the :quota parsed from the rate-limit headers when present.

Kinds

:kindStatusMeaning
:auth401Invalid API key.
:subscription402Freebie expired or subscription is not active.
:validation422Invalid parameters; also raised client-side for >10 names.
:rate_limit429Request limit reached. :quota is always populated.
:transportnilNetwork failure, timeout, or a non-JSON body.
:demografixotherAny other non-2xx response.

Match on :kind to branch on the error type.

Summary

Types

kind()

@type kind() ::
  :auth | :subscription | :validation | :rate_limit | :transport | :demografix

t()

@type t() :: %Demografix.Error{
  __exception__: true,
  kind: kind(),
  message: String.t(),
  quota: Demografix.Quota.t() | nil,
  status: integer() | nil
}