use thiserror::Error;
pub type GmailCodeResult<T> = Result<T, GmailCodeError>;
#[derive(Debug, Error)]
pub enum GmailCodeError {
#[error("invalid config: {0}")]
InvalidConfig(String),
#[error("invalid base url `{0}`")]
InvalidBaseUrl(String),
#[error("invalid request path `{0}`")]
InvalidPath(String),
#[error("request failed: {0}")]
Transport(#[from] reqwest::Error),
#[error("failed to process json payload: {0}")]
Json(#[from] serde_json::Error),
#[error("request to `{url}` returned HTTP {status}: {body}")]
HttpStatus {
url: String,
status: u16,
body: String,
},
#[error("failed to decode Gmail message body for part `{part_id}`: {source}")]
BodyDecode {
part_id: String,
#[source]
source: base64::DecodeError,
},
#[error("Gmail message body for part `{part_id}` is not valid UTF-8: {source}")]
BodyUtf8 {
part_id: String,
#[source]
source: std::string::FromUtf8Error,
},
}