feat(error): enhance error handling for configuration issues

- add specific error variants for unset directory, home expansion failure, and directory creation failure
- improve error reporting by providing more context in error messages
This commit is contained in:
Jeremiah Russell
2025-10-02 15:03:20 +01:00
committed by Jeremiah Russell
parent 2a62c6c1ba
commit 5d9bee1197

View File

@@ -3,10 +3,23 @@ use thiserror::Error;
/// Error messages for cull-gmail
#[derive(Debug, Error)]
pub enum Error {
/// Configuration directory not set
#[error("Configuration directory not set")]
DirectoryUnset,
/// Expansion of home directory in `{0}` failed
#[error("Expansion of home directory in `{0}` failed")]
HomeExpansionFailed(String),
/// Directory creation failed for `{0}`
#[error("Directory creation failed for `{0:?}`")]
DirectoryCreationFailed((String, Box<std::io::Error>)),
/// Error from the google_gmail1 crate
#[error("Google Gmail1 says: {0}")]
GoogleGmail1(#[from] google_gmail1::Error),
/// Error from the google_clis_common crate
#[error("Google CLIs Common says: {0}")]
InvalidOptionsError(google_clis_common::CLIError, i16),
// #[error("Google Gmail1 says: {0}")]
#[error(transparent)]
GoogleGmail1(#[from] Box<google_gmail1::Error>),
// /// Error from the google_clis_common crate
// #[error("Google CLIs Common says: {0}")]
// InvalidOptionsError(google_clis_common::CLIError, i16),
// /// Other error
// #[error("Error reported: {0}")]
// Other(#[from] String),
}