File size: 1,925 Bytes
e275025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Custom exceptions for Medical Transcriber application.

Defines specific exception types for better error handling and debugging.
"""


class MedicalTranscriberException(Exception):
    """Base exception for Medical Transcriber application."""
    pass


class AudioFileException(MedicalTranscriberException):
    """Exception raised for audio file related errors."""
    
    def __init__(self, file_path: str, message: str = "Invalid audio file"):
        self.file_path = file_path
        self.message = f"{message}: {file_path}"
        super().__init__(self.message)


class TranscriptionException(MedicalTranscriberException):
    """Exception raised during transcription process."""
    pass


class CorrectionException(MedicalTranscriberException):
    """Exception raised during LLM correction process."""
    pass


class ReportGenerationException(MedicalTranscriberException):
    """Exception raised during report generation."""
    pass


class ConfigurationException(MedicalTranscriberException):
    """Exception raised for configuration errors."""
    pass


class APIException(MedicalTranscriberException):
    """Exception raised for API communication errors."""
    
    def __init__(self, endpoint: str, status_code: int, message: str):
        self.endpoint = endpoint
        self.status_code = status_code
        self.message = f"API Error {status_code} at {endpoint}: {message}"
        super().__init__(self.message)


class ValidationException(MedicalTranscriberException):
    """Exception raised for validation errors."""
    
    def __init__(self, field: str, value: str, reason: str = "Invalid value"):
        self.field = field
        self.value = value
        self.message = f"{reason} for field '{field}': {value}"
        super().__init__(self.message)


class KnowledgeBaseException(MedicalTranscriberException):
    """Exception raised for knowledge base operations."""
    pass