# `PostHog.Emails.Error`
[🔗](https://github.com/posthog/posthog-elixir/blob/v2.20.0/lib/posthog/emails/error.ex#L1)

PostHog did not queue the email or return its status, or the SDK could not tell whether it did.

Branch on `:code`, PostHog's stable error code, or on `:name`, a coarse category of the
failure. The message never contains the secret key or the request body.

## Fields

- `:name` - the category, one of `t:name/0`.
- `:code` - PostHog's error code, such as `"quota_limited"` or `"recipient_suppressed"`, or an
  SDK code: `"missing_secret_key"`, `"missing_app_host"`, `"client_disabled"`,
  `"client_closed"`, `"network_error"`, `"api_error"` (an answer without a code), `"unexpected_error"`, or an
  `"invalid_*"` code for an option the SDK refused before any request.
- `:message` - human-readable message.
- `:status_code` - the HTTP status, when PostHog answered.
- `:why` and `:fix` - why PostHog refused the email and how to fix it, when it said.
- `:docs_url` - a link to the docs for the error, when PostHog sent one.
- `:field` - the option the error is about, such as `"to"`.
- `:retry_after_ms` - how long PostHog asked the client to wait before it sends again.

# `name`

```elixir
@type name() ::
  :validation_error
  | :missing_api_key
  | :invalid_permission
  | :not_found
  | :concurrent_idempotent_requests
  | :invalid_idempotent_request
  | :rate_limit_exceeded
  | :monthly_quota_exceeded
  | :service_unavailable
  | :application_error
```

A coarse category of the failure.

# `t`

```elixir
@type t() :: %PostHog.Emails.Error{
  __exception__: true,
  code: String.t(),
  docs_url: String.t() | nil,
  field: String.t() | nil,
  fix: String.t() | nil,
  message: String.t(),
  name: name(),
  retry_after_ms: non_neg_integer() | nil,
  status_code: pos_integer() | nil,
  why: String.t() | nil
}
```

An email request that failed.

---

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