risa.errors¶
The exceptions risa raises.
Every exception derives from RisaError, builds its own message, and keeps the
details it was raised with as attributes, so callers can branch on fields instead
of parsing the message.
AlreadyRespondedError
¶
ArgBindError
¶
CodecUnavailableError
¶
CustomIdOverflowError
¶
DuplicateHandlerError
¶
DuplicateHandlerError(
view_name: str,
token: str,
*,
first_id: str,
first_version: int,
second_id: str,
second_version: int,
)
Bases: RisaError
Raised when two handlers of one view would route under the same token.
Attributes:
-
view_name(str) –The view both handlers belong to.
-
token(str) –The token both handlers hash to.
-
first_id(str) –The id of the first handler.
-
first_version(int) –The version of the first handler.
-
second_id(str) –The id of the second handler.
-
second_version(int) –The version of the second handler.
DuplicateViewError
¶
HandlerSignatureError
¶
LayoutError
¶
LockTimeoutError
¶
NoViewError
¶
Bases: RisaError
Raised when an operation needs the view's state, but the context has none.
That is the case in on_outdated and on_state_missing, after ctx.replace gave the
message to another view, and in a context kept past the end of its dispatch.
Attributes:
-
view_name(str) –The view the context belongs to.
-
attempted(str) –The operation that needed the state.
SerializationError
¶
Bases: RisaError
Base class of the errors raised while writing or reading view state.
SignatureMismatchError
¶
SignatureMismatchError(
view_name: str, handler_id: str, version: int, *, found: str, expected: str
)
Bases: RisaError
Logged, not raised, when a click carries wire arguments for another handler signature.
The handler's wire parameters changed without a version bump. risa logs this error
and routes the click to View.on_outdated. Bump the version in
@risa.handler(version=...) so the old components are retired instead.
Attributes:
-
view_name(str) –The view the handler belongs to.
-
handler_id(str) –The handler's id.
-
version(int) –The handler's version.
-
found(str) –The fingerprint the component carries.
-
expected(str) –The fingerprint of the handler's current signature.
StateConflictError
¶
Bases: StateError
Raised when another process wrote a view's state first.
By the time it is raised, the view already holds the state that won, so the handler
can apply its change again on top of it. A record that cannot be read raises
StateUnreadableError instead.
Attributes:
-
key(str) –The store key of the state.
-
expected(int) –The version this dispatch read.
-
found(int) –The version the store holds.
StateEncodeError
¶
Bases: SerializationError
Raised when a durable field holds a value that cannot be serialized.
Attributes:
-
view_name(str) –The view the field belongs to.
-
field(str) –The field at fault.
-
reason(str) –Why its value cannot be written.
StateNotFoundError
¶
StateNotFoundError(key: str)
Bases: StateError
Raised when a view's stored state is gone in the middle of a dispatch.
Attributes:
-
key(str) –The store key of the state.
StateOverflowError
¶
StateOverflowError(
view_name: str,
*,
needed: int,
available: int,
slots: int,
codec_name: str,
fields: Mapping[str, int] | None = None,
)
Bases: RisaError
Raised when an InMessage view's durable state does not fit its components.
Attributes:
-
view_name(str) –The view whose state overflowed.
-
needed(int) –The bytes of state to write.
-
available(int) –The bytes the rendered components can carry.
-
slots(int) –The number of interactive components.
-
codec_name(str) –The codec the state was written with.
-
fields(Mapping[str, int]) –The bytes each durable field takes, by name, in declaration order. What they leave of
neededis risa's own framing.
StateUnreadableError
¶
StateUnreadableError(key: str)
Bases: StateError
Raised when another process wrote a view's state first, in a form this code cannot read.
It can happen during a deploy, when a process with other fields wins the race. The view keeps its own state, the change is lost, and another attempt in this click raises again.
Attributes:
-
key(str) –The store key of the state.
StoreConformanceError
¶
StoreUnavailableError
¶
Bases: StateError
Raised when the store holding a view's state cannot be reached.
The state is not lost; it only cannot be read or written right now. A store reports missing state by returning nothing, never with this error.
Attributes: