Coverage for src / lexigram / contracts / workflow / errors.py: 60%
10 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
1"""Workflow-domain exception classes.
3Exceptions that cross extension-package boundaries live here so that core
4``lexigram``, ``lexigram-workflow``, and all extension packages can import
5them without cross-extension dependencies.
6"""
8from __future__ import annotations
10from lexigram.contracts.exceptions.base import LexigramError
13class SagaVersionMismatchError(LexigramError):
14 """Raised when a persisted saga state version is incompatible with the current code.
16 Attributes:
17 saga_id: ID of the saga instance with the incompatible state.
18 expected_version: The VERSION class attribute of the current saga class.
19 stored_version: The version number found in the persisted state.
20 """
22 _code: str = "LEX_ERR_WF_009"
24 def __init__(
25 self,
26 saga_id: str,
27 expected_version: int,
28 stored_version: int,
29 ) -> None:
30 super().__init__(
31 f"Saga version mismatch for '{saga_id}': "
32 f"expected v{expected_version}, stored v{stored_version}"
33 )
34 self.saga_id = saga_id
35 self.expected_version = expected_version
36 self.stored_version = stored_version
39__all__ = [
40 "SagaVersionMismatchError",
41]