# `Noizu.Discord.Error`
[🔗](https://github.com/noizu-labs-sdks/elixir-discord/blob/v0.1.0/lib/noizu/discord/error.ex#L1)

Structured error returned by every failing call as `{:error, %Noizu.Discord.Error{}}`.

Returned, never raised in the normal flow (it is a `defexception` so pagination
streams can raise it mid-enumeration).

| `:tag` | `:reason` | When |
|---|---|---|
| `:api` | Discord JSON error code (integer, e.g. `10003`) | non-2xx with the `{code, message, errors}` envelope |
| `:rate_limited` | `:rate_limited` | 429 still returned after the bounded retry gave up |
| `:http` | `:http_error` | non-2xx without a Discord envelope |
| `:transport` | the transport exception | connection refused, timeout, … |
| `:config` | `:missing_token` | no bot token configured |
| `:validation` | an atom (e.g. `:embed_too_long`) | client-side validation (embeds, webhook URL, …) |

* `:status` — HTTP status when a response arrived.
* `:body` — decoded JSON (or raw body); for `:api` errors this holds the nested
  `"errors"` object describing field-level failures.
* `:summary` — Discord's `message` string when present.

# `t`

```elixir
@type t() :: %Noizu.Discord.Error{
  __exception__: term(),
  body: term(),
  message: String.t(),
  reason: term(),
  status: pos_integer() | nil,
  summary: String.t() | nil,
  tag: :api | :rate_limited | :http | :transport | :config | :validation | nil
}
```

# `config`

```elixir
@spec config(atom(), String.t()) :: t()
```

Missing configuration (e.g. no bot token).

# `from_response`

```elixir
@spec from_response(pos_integer(), term()) :: t()
```

Builds an error from an HTTP status and decoded response body.

# `transport`

```elixir
@spec transport(term()) :: t()
```

Wraps a transport-level failure.

# `validation`

```elixir
@spec validation(atom(), String.t()) :: t()
```

Client-side validation failure.

---

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