redisctl_config/
error.rs

1//! Error types for redisctl-config
2
3use thiserror::Error;
4
5/// Errors that can occur during configuration operations
6#[derive(Error, Debug)]
7pub enum ConfigError {
8    #[error("Failed to load config from {path}: {source}")]
9    LoadError {
10        path: String,
11        #[source]
12        source: std::io::Error,
13    },
14
15    #[error("Failed to save config to {path}: {source}")]
16    SaveError {
17        path: String,
18        #[source]
19        source: std::io::Error,
20    },
21
22    #[error("Failed to parse config: {0}")]
23    ParseError(#[from] toml::de::Error),
24
25    #[error("Failed to serialize config: {0}")]
26    SerializeError(#[from] toml::ser::Error),
27
28    #[error("Profile '{name}' not found")]
29    ProfileNotFound { name: String },
30
31    #[error("No {deployment_type} profiles configured. {suggestion}")]
32    NoProfilesOfType {
33        deployment_type: String,
34        suggestion: String,
35    },
36
37    #[error("Failed to resolve credential: {0}")]
38    CredentialError(String),
39
40    #[cfg(feature = "secure-storage")]
41    #[error("Keyring error: {0}")]
42    KeyringError(String),
43
44    #[error("Environment variable expansion failed: {0}")]
45    EnvExpansionError(String),
46
47    #[error("Failed to determine config directory")]
48    ConfigDirError,
49
50    #[error("IO error: {0}")]
51    IoError(#[from] std::io::Error),
52}
53
54/// Result type for configuration operations
55pub type Result<T> = std::result::Result<T, ConfigError>;