Exceptions¶
The exception hierarchy maps HTTP status codes to typed exceptions. All HTTP exceptions inherit from
ForecastHTTPError and carry status_code, response_body, and url attributes.
exceptions ¶
Exception hierarchy for the Harvest Forecast API client.
__all__
module-attribute
¶
__all__ = [
"ForecastAuthError",
"ForecastError",
"ForecastHTTPError",
"ForecastNotFoundError",
"ForecastRateLimitError",
"ForecastServerError",
"ForecastValidationError",
]
ForecastError ¶
Bases: Exception
Base for all exceptions raised by harvest_forecast.
ForecastHTTPError ¶
Bases: ForecastError
HTTP error from the Forecast API.
Carries status_code, response_body, and url. Subclasses map specific status-code ranges; this class serves as the catch-all for unrecognised codes and as the base for all HTTP exceptions.
Source code in src/harvest_forecast/exceptions.py
from_response
classmethod
¶
Source code in src/harvest_forecast/exceptions.py
ForecastAuthError ¶
Bases: ForecastHTTPError
401 or 403 — authentication or authorization failure.
Source code in src/harvest_forecast/exceptions.py
ForecastNotFoundError ¶
Bases: ForecastHTTPError
404 — resource not found.
Source code in src/harvest_forecast/exceptions.py
ForecastRateLimitError ¶
ForecastRateLimitError(
status_code: int,
response_body: str,
url: str,
*,
retry_after: float | None = None,
)
Bases: ForecastHTTPError
429 — rate limited. Carries retry_after from the Retry-After header.
Source code in src/harvest_forecast/exceptions.py
ForecastServerError ¶
ForecastValidationError ¶
Bases: ForecastHTTPError
400 or 422 — API returned a validation error body.