Spaces:
Sleeping
Sleeping
Download app/core/exceptions.py from abhisheksan/multiutility-server: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/spaces/abhisheksan/multiutility-server/resolve/main/app/core/exceptions.py
- Command line
-
hf download hf://spaces/abhisheksan/multiutility-server/app/core/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/abhisheksan/multiutility-server/resolve/main/app/core/exceptions.py
1.71 kB
| """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) |