Noizu.Telegram.Error exception (Noizu Telegram v0.1.0)

Copy Markdown View Source

Error struct for Bot API failures.

Fields: :message, :status (HTTP status), :body (raw decoded body), :reason (Telegram error_code), :summary (Telegram description), :tag (:api | :rate_limited | :http | :transport | :config | :validation), :retry_after (seconds, from a 429's parameters.retry_after).

Text is redacted: bot tokens never appear in message/summary output.

Summary

Functions

Configuration error (e.g. missing token).

Build an error from an HTTP response. Telegram envelope: %{"ok" => false, "error_code" => 429, "description" => "...", "parameters" => %{"retry_after" => 5}}.

Wrap a transport (network) exception; the message is token-redacted.

Client-side validation error (bad arguments before any request).

Types

t()

@type t() :: %Noizu.Telegram.Error{
  __exception__: term(),
  body: term(),
  message: String.t() | nil,
  reason: integer() | nil,
  retry_after: non_neg_integer() | nil,
  status: integer() | nil,
  summary: String.t() | nil,
  tag: atom()
}

Functions

config(reason, message, client \\ nil)

@spec config(atom(), String.t(), Noizu.Telegram.Client.t() | nil) :: t()

Configuration error (e.g. missing token).

from_response(status, body, client \\ nil)

@spec from_response(integer(), term(), Noizu.Telegram.Client.t() | nil) :: t()

Build an error from an HTTP response. Telegram envelope: %{"ok" => false, "error_code" => 429, "description" => "...", "parameters" => %{"retry_after" => 5}}.

transport(exception, client \\ nil)

@spec transport(Exception.t(), Noizu.Telegram.Client.t() | nil) :: t()

Wrap a transport (network) exception; the message is token-redacted.

validation(reason, message, client \\ nil)

@spec validation(atom(), String.t(), Noizu.Telegram.Client.t() | nil) :: t()

Client-side validation error (bad arguments before any request).