Zazu.Error exception (zazu v0.2.1)

Copy Markdown View Source

The API error envelope, mirroring the other Zazu SDKs' hierarchy: {"error" => {"type" => ..., "message" => ..., "param" => ...}}.

Match on :kind instead of subclassing:

  • :authentication — 401
  • :forbidden — 403
  • :not_found — 404
  • :validation — 422
  • :rate_limit — 429 (:retry_after carries the Retry-After seconds)
  • :server — 5xx
  • :api — any other non-2xx

Summary

Types

kind()

@type kind() ::
  :authentication
  | :forbidden
  | :not_found
  | :validation
  | :rate_limit
  | :server
  | :api

t()

@type t() :: %Zazu.Error{
  __exception__: true,
  body: map(),
  kind: kind(),
  message: String.t(),
  param: String.t() | nil,
  request_id: String.t() | nil,
  retry_after: non_neg_integer() | nil,
  status: pos_integer(),
  type: String.t() | nil
}