objectstore_service/
error.rs

1use thiserror::Error;
2
3/// Error type for service operations.
4#[derive(Debug, Error)]
5pub enum ServiceError {
6    /// IO errors related to payload streaming or file operations.
7    #[error("i/o error: {0}")]
8    Io(#[from] std::io::Error),
9
10    /// Errors related to de/serialization.
11    #[error("serde error: {context}")]
12    Serde {
13        /// Context describing what was being serialized/deserialized.
14        context: String,
15        /// The underlying serde error.
16        #[source]
17        cause: serde_json::Error,
18    },
19
20    /// All errors stemming from the reqwest client, used in multiple backends to send requests to
21    /// e.g. GCP APIs.
22    /// These can be network errors encountered when sending the requests, but can also indicate
23    /// errors returned by the API itself.
24    #[error("reqwest error: {context}")]
25    Reqwest {
26        /// Context describing the request that failed.
27        context: String,
28        /// The underlying reqwest error.
29        #[source]
30        cause: reqwest::Error,
31    },
32
33    /// Errors related to de/serialization and parsing of object metadata.
34    #[error("metadata error: {0}")]
35    Metadata(#[from] objectstore_types::Error),
36
37    /// Errors encountered when attempting to authenticate with GCP.
38    #[error("GCP authentication error: {0}")]
39    GcpAuth(#[from] gcp_auth::Error),
40
41    /// Any other error stemming from one of the storage backends, which might be specific to that
42    /// backend or to a certain operation.
43    #[error("storage backend error: {context}")]
44    Generic {
45        /// Context describing the operation that failed.
46        context: String,
47        /// The underlying error, if available.
48        #[source]
49        cause: Option<Box<dyn std::error::Error + Send + Sync>>,
50    },
51}
52
53/// Result type for service operations.
54pub type ServiceResult<T> = Result<T, ServiceError>;