#[expect(
clippy::module_name_repetitions,
reason = "the error types are the primary public surface of this module"
)]
#[derive(Debug, thiserror::Error)]
pub enum FetchError {
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("failed to clone request for creation of cache policy")]
FailedToCloneRequest,
#[error("HTTP {status} from GLW server at {url}: {body}")]
BadStatus {
status: reqwest::StatusCode,
url: String,
body: String,
},
#[error("GLW response body exceeded the {limit}-byte limit")]
ResponseTooLarge {
limit: usize,
},
#[error("invalid GLW base URL: {0}")]
InvalidBaseUrl(#[from] url::ParseError),
#[error("JSON decode error: {0}")]
Json(#[from] serde_json::Error),
#[error("invalid event data: {0}")]
Parse(#[from] ParseError),
}
#[expect(
clippy::module_name_repetitions,
reason = "the error types are the primary public surface of this module"
)]
#[derive(Debug, thiserror::Error)]
pub enum ParseError {
#[error("field {field} out of range: got {value}, expected {allowed}")]
OutOfRange {
field: &'static str,
value: String,
allowed: &'static str,
},
}
#[expect(
clippy::module_name_repetitions,
reason = "the error types are the primary public surface of this module"
)]
#[derive(Debug, thiserror::Error)]
pub enum GlwEventCacheError {
#[error("error decoding the JSON serialized CachePolicy: {0}")]
CachePolicyJsonDecodeError(#[from] serde_json::Error),
#[error("redb database error: {0}")]
DatabaseError(#[from] redb::DatabaseError),
#[error("redb transaction error: {0}")]
TransactionError(#[from] redb::TransactionError),
#[error("redb table error: {0}")]
TableError(#[from] redb::TableError),
#[error("redb storage error: {0}")]
StorageError(#[from] redb::StorageError),
#[error("redb commit error: {0}")]
CommitError(#[from] redb::CommitError),
#[error("error looking up GLW event via HTTP: {0}")]
FetchError(#[from] FetchError),
#[error("error handling system time for cache age calculations: {0}")]
SystemTimeError(#[from] std::time::SystemTimeError),
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Fetch(#[from] FetchError),
#[error(transparent)]
Parse(#[from] ParseError),
#[error(transparent)]
Cache(#[from] GlwEventCacheError),
}