use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum EnvVaultError {
#[error("Encryption failed: {0}")]
EncryptionFailed(String),
#[error("Decryption failed — wrong password or corrupted data")]
DecryptionFailed,
#[error("Key derivation failed: {0}")]
KeyDerivationFailed(String),
#[error("Vault not found at {0}")]
VaultNotFound(PathBuf),
#[error("Vault already exists at {0}")]
VaultAlreadyExists(PathBuf),
#[error("Invalid vault format: {0}")]
InvalidVaultFormat(String),
#[error("HMAC verification failed — vault file may be tampered")]
HmacMismatch,
#[error("HMAC error: {0}")]
HmacError(String),
#[error("Secret '{0}' not found")]
SecretNotFound(String),
#[error("Secret '{0}' already exists (use `set` to update)")]
SecretAlreadyExists(String),
#[error("Keyfile error: {0}")]
KeyfileError(String),
#[error("Keyring error: {0}")]
KeyringError(String),
#[error("Config file error: {0}")]
ConfigError(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
SerializationError(String),
#[error("Command failed: {0}")]
CommandFailed(String),
#[error("User cancelled operation")]
UserCancelled,
#[error("Password mismatch — passwords do not match")]
PasswordMismatch,
#[error("Child process exited with code {0}")]
ChildProcessFailed(i32),
#[error("No command specified — use `envvault run -- <command>`")]
NoCommandSpecified,
#[error("Audit error: {0}")]
AuditError(String),
#[error("Editor error: {0}")]
EditorError(String),
#[error("Environment '{0}' not found — no vault file exists")]
EnvironmentNotFound(String),
#[error("Clipboard error: {0}")]
ClipboardError(String),
#[error("Command not allowed: {0}")]
CommandNotAllowed(String),
}
pub type Result<T> = std::result::Result<T, EnvVaultError>;