refget_client/error.rs
1//! Error types for the refget client.
2
3/// Errors that can occur when communicating with a refget server.
4#[derive(Debug, thiserror::Error)]
5pub enum ClientError {
6 /// HTTP transport error.
7 #[error("HTTP error: {0}")]
8 Http(#[from] reqwest::Error),
9
10 /// Server returned a non-2xx status (other than 404).
11 #[error("Server error: HTTP {status}: {body}")]
12 ServerError { status: u16, body: String },
13
14 /// Server returned 404.
15 #[error("Not found: {0}")]
16 NotFound(String),
17
18 /// Failed to deserialize response JSON.
19 #[error("Deserialization error: {0}")]
20 Deserialize(#[from] serde_json::Error),
21
22 /// Invalid base URL.
23 #[error("Invalid URL: {0}")]
24 InvalidUrl(String),
25}
26
27/// Result type for client operations.
28pub type ClientResult<T> = Result<T, ClientError>;