| 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}") | |