class DomainError(Exception): """Base domain error.""" class EntityNotFoundError(DomainError): def __init__(self, entity_type: str, entity_id: str): super().__init__(f"{entity_type} not found: {entity_id}") self.entity_type = entity_type self.entity_id = entity_id class ValidationError(DomainError): def __init__(self, message: str, field: str | None = None): super().__init__(message) self.field = field class FileParsingError(DomainError): pass class ExportError(DomainError): pass class ServiceCommunicationError(DomainError): def __init__(self, service_name: str, message: str): super().__init__(f"Error communicating with {service_name}: {message}") self.service_name = service_name