Errors¶
Exception hierarchy for FSM configuration and runtime errors.
FSMError
¶
Bases: Exception
Base exception for all PyStator errors.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Human-readable error description. |
|
context |
Additional context about the error. |
|
code |
Machine-readable error code for programmatic handling. |
Source code in src/pystator/errors.py
to_dict
¶
Serialize error to dictionary.
ConfigurationError
¶
InvalidTransitionError
¶
InvalidTransitionError(message: str, current_state: str, trigger: str, context: dict[str, Any] | None = None)
Bases: FSMError
Transition is not allowed from the current state.
Attributes:
| Name | Type | Description |
|---|---|---|
current_state |
The state from which the transition was attempted. |
|
trigger |
The event that triggered the attempted transition. |
Source code in src/pystator/errors.py
to_dict
¶
Serialize error to dictionary.
GuardRejectedError
¶
GuardRejectedError(message: str, current_state: str, trigger: str, guard_name: str, guard_result: Any = None, context: dict[str, Any] | None = None)
Bases: InvalidTransitionError
Transition blocked by a guard condition.
Attributes:
| Name | Type | Description |
|---|---|---|
guard_name |
The name of the guard that rejected the transition. |
|
guard_result |
Additional information about the guard evaluation. |
Source code in src/pystator/errors.py
to_dict
¶
Serialize error to dictionary.
UndefinedStateError
¶
UndefinedTriggerError
¶
UndefinedTriggerError(message: str, trigger: str, available_triggers: list[str] | None = None, context: dict[str, Any] | None = None)
Bases: FSMError
Event trigger not defined in the machine (strict mode only).
Attributes:
| Name | Type | Description |
|---|---|---|
trigger |
The undefined event trigger. |
|
available_triggers |
List of valid triggers for reference. |
Source code in src/pystator/errors.py
to_dict
¶
Serialize error to dictionary.
GuardNotFoundError
¶
ActionNotFoundError
¶
TimeoutExpiredError
¶
TimeoutExpiredError(message: str, state_name: str, timeout_seconds: float, elapsed_seconds: float, context: dict[str, Any] | None = None)
Bases: FSMError
State timeout has expired.
Source code in src/pystator/errors.py
to_dict
¶
Serialize error to dictionary.
TerminalStateError
¶
Bases: InvalidTransitionError
Attempted to transition from a terminal state.
Source code in src/pystator/errors.py
to_dict
¶
Serialize error to dictionary.
StaleVersionError
¶
StaleVersionError(entity_id: str, expected_version: int, actual_version: int, context: dict[str, Any] | None = None)
Bases: FSMError
Optimistic locking conflict -- entity was modified concurrently.
Attributes:
| Name | Type | Description |
|---|---|---|
entity_id |
The entity whose state was stale. |
|
expected_version |
The version the caller expected. |
|
actual_version |
The current version in the store. |
Source code in src/pystator/errors.py
to_dict
¶
Serialize error to dictionary.