File size: 3,134 Bytes
92fd1a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dbe78dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""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}")