Skip to main content

best_encrypt/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum EncryptError {
5    #[error("Vault not found. Run 'encrypt init' first.")]
6    VaultNotFound,
7
8    #[error("Vault is locked. Run 'encrypt setup <password>' to unlock secrets.")]
9    VaultLocked,
10
11    #[error("Invalid password.")]
12    InvalidPassword,
13
14    #[error("Secret \"{0}\" not found.")]
15    SecretNotFound(String),
16
17    #[error("Failed to decrypt secret: {0}")]
18    DecryptionFailed(String),
19
20    #[error("Vault is locked and no valid password found. Set ENCRYPT_PASSWORD environment variable or provide password parameter.")]
21    NoValidPassword,
22
23    #[error("No secrets to lock. Use 'encrypt set' to add secrets first.")]
24    NoSecretsToLock,
25
26    #[error("IO error: {0}")]
27    Io(#[from] std::io::Error),
28
29    #[error("JSON error: {0}")]
30    Json(#[from] serde_json::Error),
31
32    #[error("Crypto error: {0}")]
33    Crypto(String),
34
35    #[error("Base64 error: {0}")]
36    Base64(#[from] base64::DecodeError),
37
38    #[error("Hex error: {0}")]
39    Hex(#[from] hex::FromHexError),
40}
41
42pub type Result<T> = std::result::Result<T, EncryptError>;