SuperCache.Cluster.Error exception (SuperCache v1.7.0)

Copy Markdown View Source

Normalized error for distributed SuperCache operations.

Every failure that crosses a node boundary — an unreachable primary, an :erpc timeout, a remote exception, or an exit raised while applying an operation — is converted into this exception before it reaches a caller. That keeps raw :exit signals and transport-specific tuples out of application code.

Fields

FieldMeaning
operationOperation that failed, usually {module, function} or an atom
partitionPartition index the operation targeted, when known
nodeNode the operation was sent to, when known
modeReplication or read mode active for the operation, when known
reasonNormalized underlying reason (:nodedown, :timeout, …)
messageOptional caller-supplied message; overrides the generated one

Error contract

Bang APIs (put!/1, get!/2, …) raise this exception. Non-bang APIs (put/1, get/2, …) return {:error, %SuperCache.Cluster.Error{}} instead of raising or leaking an exit.

Examples

error = %SuperCache.Cluster.Error{
  operation: :put,
  partition: 3,
  node: :"cache@10.0.0.2",
  mode: :strong,
  reason: :nodedown
}

Exception.message(error)
# => "distributed operation put failed on partition 3 at node :"cache@10.0.0.2" (mode :strong): nodedown"

Summary

Types

operation()

@type operation() ::
  atom() | {module(), atom()} | {module(), atom(), arity()} | term()

t()

@type t() :: %SuperCache.Cluster.Error{
  __exception__: term(),
  message: String.t() | nil,
  mode: atom() | nil,
  node: node() | nil,
  operation: operation() | nil,
  partition: non_neg_integer() | nil,
  reason: term()
}