"""Logic exceptions.""" class LogicError(Exception): """Generic exception that may be thrown on business rules validation errors. Intended to be thrown in business logic layer and processed on the same or the top level layers. The use case is the same as payment.utils.format_error.validation_error but without leaking the HTTP abstraction into the logic layer. """ class EntityDoesNotExist(Exception): """ Exception to be thrown when an entity is expected to exist but does not. Intended to be thrown in business logic layer and processed on the same or the top level layers. The use case is the same as in BaseModel.get_by_id_or_error but without leaking the HTTP abstraction into the logic layer. """ def __init__(self, object_type: object, object_id: int | str): self.object_type = object_type self.object_id = object_id super().__init__(f'{object_type} {object_id} does not exist.')