Source code for minos.aggregate.exceptions

from __future__ import (
    annotations,
)

from typing import (
    TYPE_CHECKING,
)

from minos.common import (
    MinosException,
)

if TYPE_CHECKING:
    from .entities import (
        RootEntity,
    )
    from .events import (
        Event,
    )


[docs]class AggregateException(MinosException): """Base Aggregate module exception"""
[docs]class EventRepositoryException(AggregateException): """Base event repository exception."""
[docs]class EventRepositoryConflictException(EventRepositoryException): """Exception to be raised when some ``EventEntry`` raises a conflict."""
[docs] def __init__(self, error_message: str, offset: int): super().__init__(error_message) self.offset = offset
[docs]class TransactionRepositoryException(AggregateException): """Base transaction repository exception."""
[docs]class TransactionRepositoryConflictException(TransactionRepositoryException): """Exception to be raised when a transaction has invalid status."""
[docs]class TransactionNotFoundException(TransactionRepositoryException): """Exception to be raised when some transaction is not found on the repository."""
[docs]class SnapshotRepositoryException(AggregateException): """Base snapshot exception."""
[docs]class SnapshotRepositoryConflictException(SnapshotRepositoryException): """Exception to be raised when current version is newer than the one to be processed."""
[docs] def __init__(self, previous: RootEntity, event: Event): self.previous = previous self.event = event super().__init__( f"Version for {repr(previous.classname)} root entity must be " f"greater than {previous.version}. Obtained: {event.version}" )
[docs]class NotFoundException(SnapshotRepositoryException): """Exception to be raised when a ``RootEntity`` is not found on the repository."""
[docs]class AlreadyDeletedException(SnapshotRepositoryException): """Exception to be raised when a ``RootEntity`` is already deleted from the repository."""
[docs]class ValueObjectException(AggregateException): """If an attribute of an immutable class is modified, this exception will be raised"""
[docs]class RefException(AggregateException): """Exception to be raised when some reference can not be resolved."""