Trans_for_doctors / common /exceptions.py
Mintik24's picture
🎉 Полный рефакторинг проекта Medical Transcriber
e275025
Raw
History Blame Contribute Delete
1.93 kB
"""
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