Mailglass.TenancyError exception (Mailglass v0.1.0)

Copy Markdown View Source

Raised when tenant context is required but not stamped on the process.

Mailglass.Tenancy.tenant_id!/0 raises this when the calling process has not been stamped via Mailglass.Tenancy.put_current/1 (typically from an on_mount/4 callback, Plug, or test setup). Callers that already hold tenant context may use tenant_id!/0 as a fail-loud accessor; callers that want the configured default instead should use Mailglass.Tenancy.current/0.

Types

  • :unstamped — no tenant_id present in the process dictionary
  • :webhook_tenant_unresolved — the configured Mailglass.Tenancy resolver returned {:error, _} from resolve_webhook_tenant/1 for an authenticated webhook request (Phase 4 D-14). Distinct from :unstamped — the request is cryptographically verified, but the adopter's tenancy module could not map it to a known tenant. Plan 05 formalizes the optional @callback resolve_webhook_tenant/1 and the docs/api_stability.md §Tenancy lock; Plan 04 Task 2 adds the atom as a precondition for Mailglass.Webhook.Plug's 422 rescue clause.

Never retryable — the caller failed to establish tenant context.

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.TenancyError{
  __exception__: true,
  cause: Exception.t() | nil,
  context: %{required(atom()) => term()},
  message: String.t(),
  type: :unstamped | :webhook_tenant_unresolved
}

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.TenancyError struct.

Options

  • :cause — an underlying exception to wrap (kept out of JSON output).
  • :context — a map of non-PII metadata about the call site.