The public error returned by Absurd operations.
Errors keep a stable :kind and human-readable :message while retaining
bounded diagnostic context. Database errors may also expose their SQLSTATE
without requiring callers to match on Postgrex internals.
Examples
iex> error = Absurd.Error.new(:validation, "queue must not be empty")
iex> {error.kind, Exception.message(error)}
{:validation, "queue must not be empty"}
Summary
Functions
Converts a database exception into the public error envelope.
Builds an error with optional diagnostic fields.
Types
@type kind() ::
:validation
| :configuration
| :database
| :ambiguous
| :protocol
| :schema_incompatible
| :cancelled
| :failed_run
| :timeout
| :unknown_task
The stable category of an Absurd error.
@type t() :: %Absurd.Error{ __exception__: term(), cause: term(), kind: kind(), message: String.t(), metadata: map(), operation: atom() | nil, sqlstate: String.t() | nil }
A public Absurd error value.
Functions
@spec from_exception(Exception.t(), atom() | nil, keyword()) :: t()
Converts a database exception into the public error envelope.
Absurd SQLSTATE AB001 is classified as :cancelled; AB002 is classified
as :failed_run. Pass ambiguous?: true for a mutating operation whose
established connection was lost before its outcome was observed. Connection
checkout timeouts are never ambiguous because no query was issued.
Builds an error with optional diagnostic fields.
Supported options are :operation, :sqlstate, :cause, and :metadata.