Skip to main content

email_extract/
error.rs

1//! Error types for email parsing
2
3use thiserror::Error;
4
5/// Errors that can occur during email parsing
6#[derive(Error, Debug)]
7pub enum ParseError {
8    /// Failed to parse the email structure
9    #[error("Failed to parse email structure: {0}")]
10    Structure(String),
11
12    /// Failed to decode email content
13    #[error("Failed to decode content: {0}")]
14    Decode(String),
15
16    /// Missing required header
17    #[error("Missing required header: {0}")]
18    MissingHeader(String),
19
20    /// Invalid header format
21    #[error("Invalid header format for {header}: {details}")]
22    InvalidHeader { header: String, details: String },
23
24    /// Invalid date format
25    #[error("Invalid date format: {0}")]
26    InvalidDate(String),
27}
28
29/// Result type for email parsing operations
30pub type Result<T> = std::result::Result<T, ParseError>;