Skip to main content

gaia_client/
error.rs

1use thiserror::Error;
2
3/// Result type alias for Gaia client operations.
4pub type Result<T> = std::result::Result<T, GaiaError>;
5
6/// Errors that can occur when using the Gaia client.
7#[derive(Debug, Error)]
8pub enum GaiaError {
9    /// Error connecting to the Gaia daemon.
10    #[error("failed to connect to Gaia daemon: {0}")]
11    ConnectionError(String),
12
13    /// Error loading TLS certificates.
14    #[error("failed to load TLS certificates: {0}")]
15    TlsError(String),
16
17    /// Error reading certificate or key files.
18    #[error("failed to read certificate file: {0}")]
19    IoError(#[from] std::io::Error),
20
21    /// gRPC transport error.
22    #[error("gRPC transport error: {0}")]
23    TransportError(#[from] tonic::transport::Error),
24
25    /// gRPC status error (e.g., not found, permission denied).
26    #[error("gRPC status error: {0}")]
27    StatusError(Box<tonic::Status>),
28
29    /// Secret not found.
30    #[error("secret not found: namespace='{0}', id='{1}'")]
31    SecretNotFound(String, String),
32
33    /// Invalid configuration.
34    #[error("invalid configuration: {0}")]
35    ConfigError(String),
36
37    /// The daemon is locked and cannot serve requests.
38    #[error("daemon is locked, unlock it first")]
39    DaemonLocked,
40
41    /// The daemon is offline or unreachable.
42    #[error("daemon is offline or unreachable")]
43    DaemonOffline,
44}
45
46impl From<tonic::Status> for GaiaError {
47    fn from(status: tonic::Status) -> Self {
48        GaiaError::StatusError(Box::new(status))
49    }
50}
51