# `Mailglass.RateLimitError`
[🔗](https://github.com/szTheory/mailglass/blob/v0.1.0/lib/mailglass/errors/rate_limit_error.ex#L1)

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.

# `t`

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

# `__types__`
*since 0.1.0* 

```elixir
@spec __types__() :: [atom()]
```

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

# `new`
*since 0.1.0* 

```elixir
@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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
