Mailglass.EventLedgerImmutableError exception (Mailglass v0.1.0)

Copy Markdown View Source

Raised when the mailglass_events append-only immutability trigger fires.

The event ledger is append-only by design (D-15 project-level, D-06 phase-level). A Postgres BEFORE UPDATE OR DELETE trigger on mailglass_events raises SQLSTATE 45A01 for every mutation attempt. Mailglass.Repo.transact/1 translates that %Postgrex.Error{} into this struct so callers pattern-match a mailglass-owned error, never the raw Postgrex one.

Types

  • :update_attempt — an UPDATE statement hit the trigger
  • :delete_attempt — a DELETE statement hit the trigger

Never retryable — an immutability violation is a bug in the calling code.

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

Summary

Functions

Returns the closed set of valid :type atoms. Tested against docs/api_stability.md.

Types

t()

@type t() :: %Mailglass.EventLedgerImmutableError{
  __exception__: true,
  cause: Exception.t() | nil,
  context: %{required(atom()) => term()},
  message: String.t(),
  pg_code: String.t(),
  type: :update_attempt | :delete_attempt
}

Functions

__types__()

(since 0.1.0)
@spec __types__() :: [atom()]

Returns the closed set of valid :type atoms. Tested against docs/api_stability.md.

new(type, opts \\ [])

(since 0.1.0)
@spec new(
  atom(),
  keyword()
) :: t()

Build a Mailglass.EventLedgerImmutableError struct.

Options

  • :cause — the underlying %Postgrex.Error{} (kept out of JSON output).
  • :context — a map of non-PII metadata. :pg_code is propagated into the :pg_code struct field.
  • :pg_code — the SQLSTATE code; defaults to "45A01".