Mailglass.Error.BatchFailed exception (Mailglass v1.0.0)

Copy Markdown View Source

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).

Summary

Functions

Returns the closed set of valid :type atoms.

Types

t()

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

Functions

__types__()

(since 0.1.0)

Returns the closed set of valid :type atoms.

new(type, opts \\ [])

(since 0.1.0)
@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.