File size: 747 Bytes
10aced5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class ValidatorError(Exception):
    """Base exception for all client errors."""


class APIError(ValidatorError):
    """HTTP error returned by the API (4xx / 5xx)."""

    def __init__(self, status_code: int, detail: str) -> None:
        self.status_code = status_code
        self.detail = detail
        super().__init__(f"HTTP {status_code}: {detail}")


class TimeoutError(ValidatorError):
    """Request exceeded the configured timeout."""


class RetryExhaustedError(ValidatorError):
    """All retry attempts failed."""

    def __init__(self, attempts: int, last_error: Exception) -> None:
        self.attempts = attempts
        self.last_error = last_error
        super().__init__(f"Failed after {attempts} attempts: {last_error}")