use snafu::Snafu;
#[derive(Snafu, Debug)]
#[snafu(visibility(pub(crate)), context(suffix(false)))]
pub enum ConfigError {
#[snafu(
display("Serde Error. Cannot seriliaze or deseriliaze."),
context(false)
)]
SerdeError {
source: serde_json::Error,
},
#[cfg(feature = "secret")]
#[snafu(display("Failed to deseriliaze encrypter from keyring."))]
LoadEncrypterFailed,
#[cfg(feature = "secret")]
#[snafu(
display(
"Keyring Error.\nThis error may caused by OS' secret manager, the rsa private key cannot be saved or read."
),
)]
KeyringError,
#[snafu(
display("Encryption Error. Cannot encrypt or decrypt.\nIf it's a decrypt error, maybe it's the private key stored in keyring being incorrect, modified or recreated."),
context(false)
)]
#[cfg(feature = "secret")]
EncryptionError {
source: rsa::Error,
},
#[snafu(display("IO error. Cannot operate the file."), context(false))]
IoError {
source: std::io::Error,
},
}
pub type ConfigResult<T> = Result<T, ConfigError>;