Spaces:
Running
Running
File size: 1,905 Bytes
4fc93b8 c0426da | 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 | """Custom exception classes."""
class DeepfakeDetectionError(Exception):
"""Base exception for deepfake detection service."""
def __init__(self, message: str, status_code: int = 500):
self.message = message
self.status_code = status_code
super().__init__(self.message)
class FileDownloadError(DeepfakeDetectionError):
"""Exception raised when file download fails."""
def __init__(self, message: str, status_code: int = 400):
super().__init__(message, status_code)
class InvalidURLError(DeepfakeDetectionError):
"""Exception raised when URL is invalid."""
def __init__(self, message: str = "Invalid URL format"):
super().__init__(message, 400)
class DownloadTimeoutError(DeepfakeDetectionError):
"""Exception raised when file download times out."""
def __init__(self, message: str = "File download timed out"):
super().__init__(message, 408)
class FileSizeError(DeepfakeDetectionError):
"""Exception raised when file size exceeds limit."""
def __init__(self, message: str = "File size exceeds maximum allowed size"):
super().__init__(message, 400)
class DetectorError(DeepfakeDetectionError):
"""Exception raised when detector model fails."""
def __init__(self, message: str = "Deepfake detection failed"):
super().__init__(message, 500)
class UnsupportedModelError(DeepfakeDetectionError):
"""Exception raised when requested model is not supported."""
def __init__(self, model_name: str):
message = f"Detector model '{model_name}' is not supported"
super().__init__(message, 400)
class SetupRequiredError(Exception):
"""Wyjątek zgłaszany, gdy bot nie został jeszcze skonfigurowany na danym serwerze."""
def __init__(self, message: str = "Setup required"):
super().__init__(message, 500)
|