lmrc_vault/
error.rs

1use thiserror::Error;
2
3/// Result type for Vault operations
4pub type Result<T> = std::result::Result<T, VaultError>;
5
6/// Errors that can occur during Vault operations
7#[derive(Error, Debug)]
8pub enum VaultError {
9    /// Vault client error
10    #[error("Vault client error: {0}")]
11    Client(String),
12
13    /// Authentication error
14    #[error("Authentication failed: {0}")]
15    Authentication(String),
16
17    /// Secret not found
18    #[error("Secret not found at path: {path}")]
19    SecretNotFound { path: String },
20
21    /// Secret write error
22    #[error("Failed to write secret: {0}")]
23    SecretWrite(String),
24
25    /// Secret read error
26    #[error("Failed to read secret: {0}")]
27    SecretRead(String),
28
29    /// Policy management error
30    #[error("Policy error: {0}")]
31    Policy(String),
32
33    /// Initialization error
34    #[error("Vault initialization error: {0}")]
35    Initialization(String),
36
37    /// Unseal error
38    #[error("Vault unseal error: {0}")]
39    Unseal(String),
40
41    /// Deployment error
42    #[error("Deployment error: {0}")]
43    Deployment(String),
44
45    /// Helm operation error
46    #[error("Helm error: {0}")]
47    Helm(String),
48
49    /// Kubernetes operation error
50    #[error("Kubernetes error: {0}")]
51    Kubernetes(#[from] lmrc_kubernetes::Error),
52
53    /// SSH error
54    #[error("SSH error: {0}")]
55    Ssh(#[from] lmrc_ssh::Error),
56
57    /// Invalid configuration
58    #[error("Invalid configuration: {0}")]
59    InvalidConfig(String),
60
61    /// Configuration error
62    #[error("Configuration error: {0}")]
63    Configuration(String),
64
65    /// Installation error
66    #[error("Installation error: {0}")]
67    Installation(String),
68
69    /// Service control error
70    #[error("Service control error: {0}")]
71    ServiceControl(String),
72
73    /// HTTP request error
74    #[error("HTTP error: {0}")]
75    Http(#[from] reqwest::Error),
76
77    /// Serialization error
78    #[error("Serialization error: {0}")]
79    Serialization(#[from] serde_json::Error),
80
81    /// I/O error
82    #[error("I/O error: {0}")]
83    Io(#[from] std::io::Error),
84
85    /// Vaultrs client error
86    #[error("Vaultrs error: {0}")]
87    Vaultrs(String),
88
89    /// Generic error
90    #[error("{0}")]
91    Other(String),
92}
93
94impl From<vaultrs::error::ClientError> for VaultError {
95    fn from(err: vaultrs::error::ClientError) -> Self {
96        VaultError::Vaultrs(err.to_string())
97    }
98}