Mailglass.RateLimitError exception (Mailglass v0.1.0)

Copy Markdown View Source

Raised when a rate limit is exceeded.

Rate-limit errors are always retryable — the caller should wait :retry_after_ms milliseconds before attempting the send again.

Types

  • :per_domain — the recipient domain is over its rate limit
  • :per_tenant — the sending tenant is over its rate limit
  • :per_stream — the delivery stream (transactional / operational / bulk) is over its rate limit

Per-kind Fields

  • :retry_after_ms — non-negative integer milliseconds the caller should wait before retrying. Defaults to 0 when the caller did not supply it.

See Mailglass.Error for the shared contract and docs/api_stability.md for the locked :type atom set.

Summary

Functions

Returns the closed set of valid :type atoms. Tested against docs/api_stability.md.

Types

t()

@type t() :: %Mailglass.RateLimitError{
  __exception__: true,
  cause: Exception.t() | nil,
  context: %{required(atom()) => term()},
  message: String.t(),
  retry_after_ms: non_neg_integer(),
  type: :per_domain | :per_tenant | :per_stream
}

Functions

__types__()

(since 0.1.0)
@spec __types__() :: [atom()]

Returns the closed set of valid :type atoms. Tested against docs/api_stability.md.

new(type, opts \\ [])

(since 0.1.0)
@spec new(
  atom(),
  keyword()
) :: t()

Build a Mailglass.RateLimitError struct.

Options

  • :cause — an underlying exception to wrap (kept out of JSON output).
  • :context — a map of non-PII metadata; :retry_after_ms is also read from context when formatting the message.
  • :retry_after_ms — milliseconds to wait before retrying. When provided, overrides the struct's default 0.