File size: 1,848 Bytes
a475b1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
"""
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)