1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, VaultError>;
5
6#[derive(Error, Debug)]
8pub enum VaultError {
9 #[error("Vault client error: {0}")]
11 Client(String),
12
13 #[error("Authentication failed: {0}")]
15 Authentication(String),
16
17 #[error("Secret not found at path: {path}")]
19 SecretNotFound { path: String },
20
21 #[error("Failed to write secret: {0}")]
23 SecretWrite(String),
24
25 #[error("Failed to read secret: {0}")]
27 SecretRead(String),
28
29 #[error("Policy error: {0}")]
31 Policy(String),
32
33 #[error("Vault initialization error: {0}")]
35 Initialization(String),
36
37 #[error("Vault unseal error: {0}")]
39 Unseal(String),
40
41 #[error("Deployment error: {0}")]
43 Deployment(String),
44
45 #[error("Helm error: {0}")]
47 Helm(String),
48
49 #[error("Kubernetes error: {0}")]
51 Kubernetes(#[from] lmrc_kubernetes::Error),
52
53 #[error("SSH error: {0}")]
55 Ssh(#[from] lmrc_ssh::Error),
56
57 #[error("Invalid configuration: {0}")]
59 InvalidConfig(String),
60
61 #[error("Configuration error: {0}")]
63 Configuration(String),
64
65 #[error("Installation error: {0}")]
67 Installation(String),
68
69 #[error("Service control error: {0}")]
71 ServiceControl(String),
72
73 #[error("HTTP error: {0}")]
75 Http(#[from] reqwest::Error),
76
77 #[error("Serialization error: {0}")]
79 Serialization(#[from] serde_json::Error),
80
81 #[error("I/O error: {0}")]
83 Io(#[from] std::io::Error),
84
85 #[error("Vaultrs error: {0}")]
87 Vaultrs(String),
88
89 #[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}