Files
cull-gmail/src/error.rs
Jeremiah Russell 2bee42d7ba 🔐 feat: Add token export/import for ephemeral environments
- Add token CLI subcommand with export/import operations
- Enable OAuth2 token persistence across clean environments
- Support for containers, CI/CD, and ephemeral compute workflows
- Compress tokens with gzip and encode as base64 for env vars
- Automatic token restoration from CULL_GMAIL_TOKEN_CACHE
- Secure file permissions (600) on restored tokens
- Add comprehensive error handling for token operations
- Update dependencies: base64, flate2, serde_json

This feature enables cull-gmail to run in ephemeral environments
like Docker containers and CI/CD pipelines without re-authentication
by exporting tokens once and restoring them via environment variables.
2025-10-21 07:47:55 +01:00

64 lines
2.2 KiB
Rust

use thiserror::Error;
/// Error messages for cull-gmail
#[derive(Debug, Error)]
pub enum Error {
/// Invalid paging mode option
#[error("Invalid paging mode option")]
InvalidPagingMode,
/// 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),
/// No labels found in mailbox
#[error("No labels found in mailbox")]
NoLabelsFound,
/// No rule selector specified (i.e. --id or --label)
#[error("No rule selector specified (i.e. --id or --label)")]
NoRuleSelector,
/// No rule for label
#[error("No rule for label {0}")]
NoRuleFoundForLabel(String),
/// No rule for label
#[error("No query string calculated for rule #{0}")]
NoQueryStringCalculated(usize),
/// No label found in the mailbox
#[error("Label {0} not found in the mailbox")]
LabelNotFoundInMailbox(String),
/// Rule not found for ID
#[error("No rule for id {0}")]
RuleNotFound(usize),
/// Label not found in the rule set
#[error("Label `{0}` not found in the rule set")]
LabelNotFoundInRules(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(transparent)]
GoogleGmail1(#[from] Box<google_gmail1::Error>),
/// Error from std::io
#[error(transparent)]
StdIO(#[from] std::io::Error),
/// Error from toml_de
#[error(transparent)]
TomlDe(#[from] toml::de::Error),
/// Error from config
#[error(transparent)]
Config(#[from] config::ConfigError),
/// Invalid message age specification
#[error("Invalid message age: {0}")]
InvalidMessageAge(String),
/// Token not found or missing
#[error("Token error: {0}")]
TokenNotFound(String),
/// File I/O error with context
#[error("File I/O error: {0}")]
FileIo(String),
/// Serialization/deserialization error
#[error("Serialization error: {0}")]
SerializationError(String),
}