Spaces:
Running
Running
File size: 1,345 Bytes
90531db | 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 | """Custom exception classes for IOC Core."""
class IOCCoreException(Exception):
"""Base exception for IOC Core."""
pass
class APIKeyMissingError(IOCCoreException):
"""Raised when required API key is not configured."""
def __init__(self, provider: str):
self.provider = provider
super().__init__(f"{provider} API key not configured")
class InvalidFileFormatError(IOCCoreException):
"""Raised when uploaded file has invalid format."""
def __init__(self, expected_format: str):
self.expected_format = expected_format
super().__init__(f"Invalid file format. Expected: {expected_format}")
class InvalidHashError(IOCCoreException):
"""Raised when hash value is invalid."""
def __init__(self, hash_value: str):
self.hash_value = hash_value
super().__init__(f"Invalid hash value: {hash_value}")
class ExternalAPIError(IOCCoreException):
"""Raised when external API call fails."""
def __init__(self, provider: str, status_code: int = None, message: str = None):
self.provider = provider
self.status_code = status_code
error_msg = f"{provider} API error"
if status_code:
error_msg += f" (status: {status_code})"
if message:
error_msg += f": {message}"
super().__init__(error_msg)
|