Exceptions
Exception classes for handling API errors.
- exception valopy.exceptions.ValoPyError[source]
Bases:
ExceptionBase exception for all ValoPy errors.
- exception valopy.exceptions.ValoPyHTTPError(message, status_code, url=None)[source]
Bases:
ValoPyErrorHTTP error with status code and URL information.
- message
The error message describing the HTTP error.
- Type:
str
- status_code
The HTTP status code.
- Type:
int
- url
The URL that caused the error, if available.
- Type:
Optional[str]
- exception valopy.exceptions.ValoPyNotFoundError(status_code, url=None)[source]
Bases:
ValoPyHTTPErrorResource not found (404).
- message
Error message indicating resource not found.
- Type:
str
- status_code
HTTP status code (404).
- Type:
int
- url
The URL that was not found.
- Type:
Optional[str]
- exception valopy.exceptions.ValoPyPermissionError(status_code, url=None, request_headers={}, redacted=False)[source]
Bases:
ValoPyHTTPErrorPermission denied (401).
- message
Error message indicating permission denied.
- Type:
str
- status_code
HTTP status code (401).
- Type:
int
- url
The URL that caused the error.
- Type:
Optional[str]
- request_headers
The request headers from the failed request.
- Type:
dict
- exception valopy.exceptions.ValoPyRateLimitError(status_code, url=None, response_headers={})[source]
Bases:
ValoPyHTTPErrorRate limit exceeded (429).
- message
Error message indicating rate limit exceeded.
- Type:
str
- status_code
HTTP status code (429).
- Type:
int
- url
The URL that exceeded the rate limit.
- Type:
Optional[str]
- rate_limit
The rate limit value from response headers.
- Type:
Optional[str]
- rate_remain
The remaining requests value from response headers.
- Type:
Optional[str]
- rate_reset
The rate limit reset time from response headers.
- Type:
Optional[str]
- exception valopy.exceptions.ValoPyRequestError(status_code, url=None)[source]
Bases:
ValoPyHTTPErrorBad request (400).
- message
Error message indicating bad request.
- Type:
str
- status_code
HTTP status code (400).
- Type:
int
- url
The URL that caused the error.
- Type:
Optional[str]
- exception valopy.exceptions.ValoPyServerError(status_code, url=None)[source]
Bases:
ValoPyHTTPErrorServer error (5xx).
- message
Error message indicating server error.
- Type:
str
- status_code
HTTP status code (5xx).
- Type:
int
- url
The URL that caused the server error.
- Type:
Optional[str]
- exception valopy.exceptions.ValoPyTimeoutError(status_code, url=None)[source]
Bases:
ValoPyHTTPErrorRequest timeout (408).
- message
Error message indicating request timeout.
- Type:
str
- status_code
HTTP status code (408).
- Type:
int
- url
The URL that timed out.
- Type:
Optional[str]
- valopy.exceptions.from_client_response_error(error, redacted)[source]
Convert an aiohttp ClientResponseError to a ValoPyHTTPError.
- Parameters:
error (aiohttp.ClientResponseError) – The original ClientResponseError.
redacted (bool) – Whether the API key in the request headers is redacted.
- Returns:
The corresponding ValoPy error matching the HTTP status code.
- Return type:
ValoPyHTTPError | ValoPyRequestError | ValoPyPermissionError | ValoPyNotFoundError | ValoPyTimeoutError | ValoPyRateLimitError | ValoPyServerError
- Raises:
ValoPyRequestError – If status code is 400.
ValoPyPermissionError – If status code is 401.
ValoPyNotFoundError – If status code is 404.
ValoPyTimeoutError – If status code is 408.
ValoPyRateLimitError – If status code is 429.
ValoPyServerError – If status code is 5xx.
ValoPyHTTPError – For any other HTTP error status codes.