Spaces:
Running
Running
| """Custom exception classes for the multi-utility server.""" | |
| from typing import Optional | |
| class MultiUtilityServerException(Exception): | |
| """Base exception class for the multi-utility server.""" | |
| def __init__(self, message: str, status_code: int = 500) -> None: | |
| self.message = message | |
| self.status_code = status_code | |
| super().__init__(self.message) | |
| class AuthenticationError(MultiUtilityServerException): | |
| """Raised when API key authentication fails.""" | |
| def __init__(self, message: str = "Invalid or missing API key") -> None: | |
| super().__init__(message, status_code=401) | |
| class InvalidVideoURLError(MultiUtilityServerException): | |
| """Raised when the provided video URL is invalid.""" | |
| def __init__(self, message: str = "Invalid YouTube URL or missing parameters") -> None: | |
| super().__init__(message, status_code=400) | |
| class SubtitlesNotFoundError(MultiUtilityServerException): | |
| """Raised when no subtitles are available for the requested language.""" | |
| def __init__(self, message: str = "No subtitles available in the requested language") -> None: | |
| super().__init__(message, status_code=404) | |
| class DownloadTimeoutError(MultiUtilityServerException): | |
| """Raised when yt-dlp operations timeout.""" | |
| def __init__(self, message: str = "Subtitle extraction timed out") -> None: | |
| super().__init__(message, status_code=408) | |
| class SubtitleExtractionError(MultiUtilityServerException): | |
| """Raised when subtitle extraction fails due to yt-dlp error.""" | |
| def __init__(self, message: str = "Subtitle extraction failed due to yt-dlp error") -> None: | |
| super().__init__(message, status_code=500) |