Skip to main content

wangamail_rs/
error.rs

1//! Error types for wangamail-rs.
2
3use thiserror::Error;
4
5/// Errors that can occur when using the Graph mail client or MCP server.
6#[derive(Error, Debug)]
7pub enum Error {
8    /// HTTP or network failure (e.g. reqwest error).
9    #[error("HTTP request failed: {0}")]
10    Request(#[from] reqwest::Error),
11
12    /// OAuth2 or token endpoint error (invalid credentials, bad response, etc.).
13    #[error("Authentication failed: {0}")]
14    Auth(String),
15
16    /// Microsoft Graph API error (e.g. sendMail returned non-202 or error body).
17    #[error("Graph API error: {0}")]
18    Graph(String),
19
20    /// Invalid configuration (missing required field, poisoned mutex, etc.).
21    #[error("Invalid configuration: {0}")]
22    Config(String),
23}
24
25/// Result type alias using this crate’s [`Error`].
26pub type Result<T> = std::result::Result<T, Error>;