Skip to main content

gie_client/
error.rs

1#[cfg(feature = "polars")]
2use polars::error::PolarsError;
3use reqwest::StatusCode;
4use thiserror::Error;
5
6/// Unified error type for AGSI/ALSI client operations.
7#[derive(Debug, Error)]
8pub enum GieError {
9    /// Transport-level error produced by `reqwest`.
10    #[error("request failed: {0}")]
11    Http(#[from] reqwest::Error),
12    /// Failed to decode JSON payload returned by the API.
13    #[error("failed to decode response JSON: {0}")]
14    Json(#[from] serde_json::Error),
15    /// Non-success HTTP status with the raw response body.
16    #[error("HTTP {status}: {body}")]
17    HttpStatus { status: StatusCode, body: String },
18    /// Structured API-level error returned by GIE.
19    #[error("GIE API error: {error}: {message}")]
20    Api { error: String, message: String },
21    /// Invalid date input provided by caller or API payload.
22    #[error("invalid date input: {0}")]
23    InvalidDateInput(String),
24    /// Invalid dataset type input provided by caller.
25    #[error("invalid dataset type input: {0}")]
26    InvalidDatasetTypeInput(String),
27    /// Invalid page input provided by caller.
28    #[error("invalid page input: {0}")]
29    InvalidPageInput(String),
30    /// Invalid page size input provided by caller.
31    #[error("invalid size input: {0}")]
32    InvalidSizeInput(String),
33    /// Invalid date range input provided by caller.
34    #[error("invalid date range input: {0}")]
35    InvalidDateRangeInput(String),
36    #[cfg(feature = "polars")]
37    /// Error while building a `polars::DataFrame`.
38    #[error("failed to build polars DataFrame: {0}")]
39    Polars(#[from] PolarsError),
40}