# `Teac.Error`
[🔗](https://codeberg.org/FullStacking/teac)

Represents an error response from the Twitch API.

All HTTP-level failures from `Teac.Api` functions return
`{:error, %Teac.Error{}}` rather than a raw response body.

## Fields

- `status` — HTTP status code (e.g. `401`, `404`)
- `type`   — Twitch error label (e.g. `"Unauthorized"`, `"Bad Request"`)
- `message` — Human-readable description from Twitch
- `ratelimit` — `%Teac.RateLimit{}` with limit/remaining/reset from response headers, or `nil`

## Pattern matching

    case Teac.Api.Clips.get(client, broadcaster_id: "123") do
      {:ok, clips, _cursor, _rl} -> ...
      {:error, %Teac.Error{status: 401}} -> # re-auth
      {:error, %Teac.Error{status: 429, ratelimit: rl}} -> wait_until(rl.reset)
      {:error, %Teac.Error{} = err} -> Logger.error(Exception.message(err))
    end

## Raising

Errors are exceptions and can be raised directly:

    {:error, err} = Teac.Api.Clips.get(client, broadcaster_id: "123")
    raise err

# `t`

```elixir
@type t() :: %Teac.Error{
  __exception__: true,
  message: String.t() | nil,
  ratelimit: Teac.RateLimit.t() | nil,
  status: non_neg_integer() | nil,
  type: String.t() | nil
}
```

---

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