Spaces:
Sleeping
Sleeping
| """Custom domain exceptions.""" | |
| class DomainException(Exception): | |
| """Base exception for all domain errors.""" | |
| pass | |
| class ValidationError(DomainException): | |
| """Raised when domain validation fails.""" | |
| pass | |
| class InvalidVideoFormatError(ValidationError): | |
| """Raised when video format is not supported.""" | |
| def __init__(self, format: str, supported_formats: list): | |
| self.format = format | |
| self.supported_formats = supported_formats | |
| super().__init__(f"Unsupported video format: {format}. Supported: {', '.join(supported_formats)}") | |
| class InvalidAudioFormatError(ValidationError): | |
| """Raised when audio format is not supported.""" | |
| def __init__(self, format: str, supported_formats: list): | |
| self.format = format | |
| self.supported_formats = supported_formats | |
| super().__init__(f"Unsupported audio format: {format}. Supported: {', '.join(supported_formats)}") | |
| class InvalidQualityLevelError(ValidationError): | |
| """Raised when quality level is not supported.""" | |
| def __init__(self, quality: str): | |
| super().__init__(f"Invalid quality level: {quality}. Must be 'high', 'medium', or 'low'") | |
| class FileSizeExceededError(ValidationError): | |
| """Raised when file size exceeds limits.""" | |
| def __init__(self, size_mb: float, max_size_mb: float): | |
| self.size_mb = size_mb | |
| self.max_size_mb = max_size_mb | |
| super().__init__(f"File size {size_mb:.1f}MB exceeds maximum {max_size_mb:.1f}MB") | |
| class ProcessingError(DomainException): | |
| """Raised when audio extraction fails.""" | |
| pass | |
| class JobNotFoundError(DomainException): | |
| """Raised when a job cannot be found.""" | |
| def __init__(self, job_id: str): | |
| self.job_id = job_id | |
| super().__init__(f"Job not found: {job_id}") | |
| class JobNotCompletedError(DomainException): | |
| """Raised when trying to access results of incomplete job.""" | |
| def __init__(self, job_id: str, status: str): | |
| self.job_id = job_id | |
| self.status = status | |
| super().__init__(f"Job {job_id} is not completed (status: {status})") | |
| class DuplicateExternalJobIdError(DomainException): | |
| """Raised when attempting to create a job with an existing external job ID.""" | |
| def __init__(self, external_job_id: str): | |
| self.external_job_id = external_job_id | |
| super().__init__(f"External job ID already exists: {external_job_id}") | |
| class AuthenticationError(DomainException): | |
| """Raised when authentication fails.""" | |
| pass | |
| class InvalidExternalJobIdFormatError(ValidationError): | |
| """Raised when external job ID format is invalid.""" | |
| def __init__(self, job_id: str, format_description: str): | |
| self.job_id = job_id | |
| self.format_description = format_description | |
| super().__init__(f"Invalid external job ID format: {job_id}. {format_description}") | |
| class NotificationFailureError(DomainException): | |
| """Raised when notification to external systems fails.""" | |
| def __init__(self, service: str, details: str): | |
| self.service = service | |
| self.details = details | |
| super().__init__(f"Notification to {service} failed: {details}") | |