Errors
The exception hierarchy.
Every error explains itself. Following the project's Odin convention, a message
names the context, the cause and a Hint: with the corrective action -- and
the hint text comes from the native library, which reads the core's own
explanation table. This package deliberately keeps no second copy of that text,
because a duplicate is a copy that can drift.
PaxodinError
Bases: Exception
Base class for every error this package raises.
Every error renders in the same three-part shape the Odin core uses for its own, so a Python traceback reads like an Odin diagnostic::
-- NOT LEADER ------------------------------------------------------------------
This node has not completed phase one for its current ballot.
leader = 2
Hint: Route to current_leader() or wait for a successful campaign.
The title names the situation, the cause says what happened with the values that matter, and the hint says what to do about it. An error never only states what failed. Hint text for a protocol error comes from the core's own table; this package keeps no copy that could drift.
Where a standard exception already means the right thing, the subclass
inherits it too: a CommitTimeout is a TimeoutError, a ValueTooLarge
is a ValueError, a StorageError is an OSError. Code that already
handles the builtin keeps working; code that wants the detail asks for it.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
int
|
The stable status code, usable in logs and comparisons. |
title |
str
|
The banner text. |
message |
A one-sentence statement of what went wrong. |
|
hint |
The corrective action, never an apology. |
|
context |
Structured detail a caller can act on programmatically. |
render
render() -> str
Render the Elm-style block: banner, cause, values, hint.
Returns:
| Type | Description |
|---|---|
str
|
The multi-line text |
UsageError
InvalidArgument
ValueTooLarge
UnsupportedKind
UnsupportedCapability
HandleClosed
ForkedHandle
ReentrantCall
BatchError
BatchPending
NoBatch
StaleToken
ForeignToken
BatchFinished
WritesUnconfirmed
AbandonedBatch
Bases: WritesUnconfirmed
A batch was left holding writes that were never confirmed durable.
The records were handed out but never acknowledged, so the node cannot tell which of them reached stable storage. Resuming would risk acting on a promise or a vote that a crash could revert.
WritesNotCopied
ReplayActive
ReplayNotActive
ProtocolError
NotLeader
LeaderCatchingUp
WindowFull
LogSealed
ConfigurationMismatch
Trimmed
CampaignDisabled
NativeError
OutOfMemory
Poisoned
ProposalLost
Bases: ProtocolError
A different value was decided in the slot this command was admitted to.
In single-leader mode there is no resubmission. If the leader loses its ballot after admitting a command, recovery can choose another value for that slot and the command is simply dropped. Reporting success here would be a lie, so the mismatch is raised instead.
InvalidTimeout
Bases: UsageError, ValueError
A timeout that cannot mean anything was supplied.
A negative, NaN or infinite duration is rejected before it reaches native code, where it would otherwise become an unbounded wait.
CommitTimeout
Bases: ProtocolError, TimeoutError
The wait ended. This did not cancel anything.
A timeout is not a rejection: peers may choose the value moments later.
admitted reports whether the command entered a slot at all.
StorageError
Bases: PaxodinError, OSError
Progress stopped with persistence uncertain.
Reopen and replay the journal rather than guessing which writes landed.
TransportError
Bases: PaxodinError, OSError
An adapter could not move a frame. Retransmission tolerates duplicates.
JournalNotOpen
JournalCorrupt
exception_for
exception_for(status: int, **context: Any) -> PaxodinError
Build the exception that matches a status code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
int
|
A bridge or protocol status code. |
required |
**context
|
Any
|
Structured detail to attach. |
{}
|
Returns:
| Type | Description |
|---|---|
PaxodinError
|
The most specific exception class for the code, or a generic |
PaxodinError
|
|
raise_for
raise_for(status: int, **context: Any) -> None
Raise if a native call reported failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
int
|
The status a native call returned. |
required |
**context
|
Any
|
Structured detail to attach. |
{}
|
Raises:
| Type | Description |
|---|---|
PaxodinError
|
When |