Skip to main content

mxr_provider_gmail/
error.rs

1use mxr_core::MxrError;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum GmailError {
6    #[error("Authentication expired — re-auth required")]
7    AuthExpired,
8
9    #[error("Not found: {0}")]
10    NotFound(String),
11
12    #[error("Rate limited — retry after {retry_after_secs}s")]
13    RateLimited { retry_after_secs: u64 },
14
15    #[error("Gmail API error (HTTP {status}): {body}")]
16    Api { status: u16, body: String },
17
18    #[error(transparent)]
19    Http(#[from] reqwest::Error),
20
21    #[error("Auth error: {0}")]
22    Auth(String),
23
24    #[error("Parse error: {0}")]
25    Parse(String),
26
27    #[error(transparent)]
28    Other(#[from] anyhow::Error),
29}
30
31impl From<GmailError> for MxrError {
32    fn from(e: GmailError) -> Self {
33        match e {
34            GmailError::NotFound(msg) => MxrError::NotFound(msg),
35            other => MxrError::Provider(other.to_string()),
36        }
37    }
38}