use thiserror::Error;
pub type Result<T> = std::result::Result<T, GaiaError>;
#[derive(Debug, Error)]
pub enum GaiaError {
#[error("failed to connect to Gaia daemon: {0}")]
ConnectionError(String),
#[error("failed to load TLS certificates: {0}")]
TlsError(String),
#[error("failed to read certificate file: {0}")]
IoError(#[from] std::io::Error),
#[error("gRPC transport error: {0}")]
TransportError(#[from] tonic::transport::Error),
#[error("gRPC status error: {0}")]
StatusError(Box<tonic::Status>),
#[error("secret not found: namespace='{0}', id='{1}'")]
SecretNotFound(String, String),
#[error("invalid configuration: {0}")]
ConfigError(String),
#[error("daemon is locked, unlock it first")]
DaemonLocked,
#[error("daemon is offline or unreachable")]
DaemonOffline,
}
impl From<tonic::Status> for GaiaError {
fn from(status: tonic::Status) -> Self {
GaiaError::StatusError(Box::new(status))
}
}