Skip to content

karenina.replay.exceptions

exceptions

Exception hierarchy for the replay layer.

Classes

ProjectionError

Bases: ReplayError

Raised by ScenarioReplayBuilder.build(strict=True) when the projection report contains unmatched targets or duplicate targets.

Attributes:

Name Type Description
report

The full ProjectionReport attached to the error for post-mortem inspection. Typed Any to avoid a circular import with karenina.replay.projection (same treatment as ReplayMissError.key). May be None when the caller did not supply one.

Source code in src/karenina/replay/exceptions.py
class ProjectionError(ReplayError):
    """Raised by ScenarioReplayBuilder.build(strict=True) when the
    projection report contains unmatched targets or duplicate targets.

    Attributes:
        report: The full ProjectionReport attached to the error for
            post-mortem inspection. Typed ``Any`` to avoid a circular
            import with ``karenina.replay.projection`` (same treatment
            as ``ReplayMissError.key``). May be None when the caller
            did not supply one.
    """

    def __init__(self, message: str, *, report: Any = None) -> None:
        super().__init__(message)
        self.report = report

ReplayError

Bases: KareninaError

Base exception for the replay layer.

Source code in src/karenina/replay/exceptions.py
class ReplayError(KareninaError):
    """Base exception for the replay layer."""

ReplayHydrationError

Bases: ReplayError

Raised when parsed_answer_fields cannot be validated against the current Answer class.

Attributes:

Name Type Description
captured_fields

The parsed field dict that failed validation.

inner

The underlying exception (typically ValidationError).

Source code in src/karenina/replay/exceptions.py
class ReplayHydrationError(ReplayError):
    """Raised when parsed_answer_fields cannot be validated against the
    current Answer class.

    Attributes:
        captured_fields: The parsed field dict that failed validation.
        inner: The underlying exception (typically ValidationError).
    """

    def __init__(
        self,
        message: str,
        *,
        captured_fields: dict[str, Any] | None = None,
        inner: BaseException | None = None,
    ) -> None:
        super().__init__(message)
        self.captured_fields = captured_fields
        self.inner = inner

ReplayMissError

Bases: ReplayError

Raised in strict mode when no matching entry is found.

Attributes:

Name Type Description
key

The ReplayKey that was looked up (Any to avoid a circular import with store.py).

Source code in src/karenina/replay/exceptions.py
class ReplayMissError(ReplayError):
    """Raised in strict mode when no matching entry is found.

    Attributes:
        key: The ReplayKey that was looked up (Any to avoid a circular
            import with store.py).
    """

    def __init__(self, message: str, *, key: Any = None) -> None:
        super().__init__(message)
        self.key = key

ReplayPersistenceError

Bases: ReplayError

Raised on version mismatch, schema failure, or malformed replay JSON.

Source code in src/karenina/replay/exceptions.py
class ReplayPersistenceError(ReplayError):
    """Raised on version mismatch, schema failure, or malformed replay JSON."""