Spaces:
Running
Running
Download src/exceptions.py from reputeradar/ioc-core: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/spaces/reputeradar/ioc-core/resolve/main/src/exceptions.py
- Command line
-
hf download hf://spaces/reputeradar/ioc-core/src/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/reputeradar/ioc-core/resolve/main/src/exceptions.py
1.35 kB
| """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) | |