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

Raised when mailglass is misconfigured.

Configuration errors are never retryable — the host application must
fix the configuration and restart. `Mailglass.Config.validate_at_boot!/0`
(lands in Plan 03) raises this at application startup.

## Types

- `:missing` — a required configuration key is not set
- `:invalid` — a key is present but the value is invalid
- `:conflicting` — two or more keys contradict each other
- `:optional_dep_missing` — an optional dependency is required for the
  selected configuration but is not loaded
- `:tracking_on_auth_stream` — open/click tracking is enabled on a mailable
  whose function name matches an auth-stream heuristic (D-38). Forbidden.
- `:tracking_host_missing` — a mailable enables opens or clicks but no
  tracking host is configured (D-32). Required for link rewriting.
- `:tracking_endpoint_missing` — tracking is enabled but no Phoenix.Token
  endpoint is configured. Set `config :mailglass, :tracking, endpoint:` or
  `config :mailglass, :adapter_endpoint` to enable open/click tracking.
- `:webhook_verification_key_missing` — a webhook provider is configured
  but its verification credentials are not set (Postmark `basic_auth`,
  SendGrid `public_key`). Phase 4 D-21.
- `:webhook_caching_body_reader_missing` — the webhook plug received a
  request with `conn.private[:raw_body]` unset, meaning the adopter has
  not wired `Mailglass.Webhook.CachingBodyReader` into their
  `Plug.Parsers` `:body_reader`. Phase 4 D-21 / revision B4.

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

# `t`

```elixir
@type t() :: %Mailglass.ConfigError{
  __exception__: true,
  cause: Exception.t() | nil,
  context: %{required(atom()) =&gt; term()},
  message: String.t(),
  type:
    :missing
    | :invalid
    | :conflicting
    | :optional_dep_missing
    | :tracking_on_auth_stream
    | :tracking_host_missing
    | :tracking_endpoint_missing
    | :webhook_verification_key_missing
    | :webhook_caching_body_reader_missing
}
```

# `__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.ConfigError` struct.

## Options

- `:cause` — an underlying exception to wrap (kept out of JSON output).
- `:context` — a map of non-PII metadata; `:key` is used for `:missing` /
  `:invalid` messages, `:dep` for `:optional_dep_missing`.

---

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