Skip to main content

iri_client/
error.rs

1use thiserror::Error;
2
3/// Errors returned by REST client operations.
4#[derive(Debug, Error)]
5pub enum ClientError {
6    /// Base URL is not a valid absolute URL.
7    #[error("invalid base URL '{0}'")]
8    InvalidBaseUrl(String),
9
10    /// Endpoint path could not be joined to the base URL.
11    #[error("invalid endpoint path '{0}'")]
12    InvalidPath(String),
13
14    /// The requested `OpenAPI` operation id is not present in the generated catalog.
15    #[error("unknown OpenAPI operation '{0}'")]
16    UnknownOperation(String),
17
18    /// A required path template parameter was not provided.
19    #[error("missing required path parameter '{parameter}' for operation '{operation_id}'")]
20    MissingPathParameter {
21        operation_id: String,
22        parameter: String,
23    },
24
25    /// HTTP transport-layer request failure.
26    #[error("request failed: {0}")]
27    Request(#[from] reqwest::Error),
28
29    /// Response body could not be parsed as JSON.
30    #[error("failed to parse JSON: {0}")]
31    Json(#[from] serde_json::Error),
32
33    /// Non-success HTTP status with response payload.
34    #[error("server returned status {status}: {body}")]
35    HttpStatus {
36        status: reqwest::StatusCode,
37        body: String,
38    },
39}