Skip to main content

yopmail_client/
error.rs

1//! Error types for the Yopmail client.
2
3use reqwest::StatusCode;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
7/// Error type for all Yopmail client operations.
8pub enum Error {
9    /// Underlying HTTP client error.
10    #[error("http error: {0}")]
11    Http(#[from] reqwest::Error),
12    /// IO error when reading or writing data.
13    #[error("io error: {0}")]
14    Io(#[from] std::io::Error),
15    /// Generic network error with a message.
16    #[error("network error: {0}")]
17    Network(String),
18    /// Parse error with a message.
19    #[error("parse error: {0}")]
20    Parse(String),
21    /// Authentication or authorization failure.
22    #[error("authentication error: {0}")]
23    Auth(String),
24    /// Recipient domain is not allowed.
25    #[error("invalid recipient domain")]
26    InvalidRecipient,
27    /// Operation is not supported by the client.
28    #[error("unsupported operation: {0}")]
29    Unsupported(String),
30    /// HTTP response returned a non-success status with body.
31    #[error("unexpected status {status}: {body}")]
32    Status { status: StatusCode, body: String },
33}
34
35/// Result type for Yopmail client operations.
36pub type Result<T> = std::result::Result<T, Error>;