# `Mailglass.Error.BatchFailed`
[🔗](https://github.com/szTheory/mailglass/blob/v1.0.0/lib/mailglass/errors/batch_failed.ex#L1)

Raised by `Mailglass.Outbound.deliver_many!/2` when one or more
deliveries in the batch have `status: :failed`.

Never raised by `deliver_many/2` — that variant returns
`{:ok, [%Delivery{}]}` where each delivery carries its own
`:status` and `:last_error`. The bang variant is opt-in for callers
who prefer exceptions.

## Types

- `:partial_failure` — at least one Delivery succeeded AND at least one failed
- `:all_failed` — every Delivery failed

## Fields

- `:failures` — list of `%Mailglass.Outbound.Delivery{}` rows with `status: :failed`.
  Successful rows are NOT included (caller can retrieve them via `deliver_many/2`
  directly if needed).

# `t`

```elixir
@type t() :: %Mailglass.Error.BatchFailed{
  __exception__: true,
  cause: Exception.t() | nil,
  context: %{required(atom()) =&gt; term()},
  failures: [Mailglass.Outbound.Delivery.t()],
  message: String.t(),
  type: :partial_failure | :all_failed
}
```

# `__types__`
*since 0.1.0* 

Returns the closed set of valid `:type` atoms.

# `new`
*since 0.1.0* 

```elixir
@spec new(
  atom(),
  keyword()
) :: t()
```

Build a `Mailglass.Error.BatchFailed` struct.

## Options

- `:cause` — an underlying exception to wrap (kept out of JSON output).
- `:context` — a map of non-PII metadata; `:count` = total deliveries attempted,
  `:failed_count` = number that failed.
- `:failures` — list of `%Mailglass.Outbound.Delivery{}` rows that failed.

---

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