Spaces:
Sleeping
Sleeping
Download sdk/python/image_search_sdk/exceptions.py from fmbishu/image-search-api: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/spaces/fmbishu/image-search-api/resolve/main/sdk/python/image_search_sdk/exceptions.py
- Command line
-
hf download hf://spaces/fmbishu/image-search-api/sdk/python/image_search_sdk/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/fmbishu/image-search-api/resolve/main/sdk/python/image_search_sdk/exceptions.py
1.85 kB
| """ | |
| Custom exceptions for the Image Search SDK. | |
| """ | |
| class ImageSearchError(Exception): | |
| """Base exception for all Image Search SDK errors.""" | |
| pass | |
| class AuthenticationError(ImageSearchError): | |
| """Raised when authentication fails.""" | |
| def __init__(self, message: str = "Authentication failed"): | |
| super().__init__(message) | |
| class RateLimitError(ImageSearchError): | |
| """Raised when rate limit is exceeded.""" | |
| def __init__(self, message: str = "Rate limit exceeded", retry_after: int = 60): | |
| super().__init__(message) | |
| self.retry_after = retry_after | |
| class ConnectionError(ImageSearchError): | |
| """Raised when connection to the service fails.""" | |
| def __init__(self, message: str = "Connection failed"): | |
| super().__init__(message) | |
| class ValidationError(ImageSearchError): | |
| """Raised when input validation fails.""" | |
| def __init__(self, message: str = "Validation failed", field: str = None): | |
| super().__init__(message) | |
| self.field = field | |
| class IndexingError(ImageSearchError): | |
| """Raised when product indexing fails.""" | |
| def __init__(self, message: str = "Indexing failed", product_id: str = None): | |
| super().__init__(message) | |
| self.product_id = product_id | |
| class SearchError(ImageSearchError): | |
| """Raised when search operation fails.""" | |
| def __init__(self, message: str = "Search failed"): | |
| super().__init__(message) | |
| class DatabaseError(ImageSearchError): | |
| """Raised when database operations fail.""" | |
| def __init__(self, message: str = "Database operation failed"): | |
| super().__init__(message) | |
| class ConfigurationError(ImageSearchError): | |
| """Raised when configuration is invalid.""" | |
| def __init__(self, message: str = "Configuration error"): | |
| super().__init__(message) | |