31 lines
885 B
Rust
31 lines
885 B
Rust
use std::fmt;
|
|
|
|
#[derive(Debug)]
|
|
pub enum ImapError {
|
|
ConnectionFailed(String),
|
|
|
|
AuthenticationFailed,
|
|
|
|
FolderNotFound(String),
|
|
|
|
MessageNotFound { uid: u32, folder: String },
|
|
|
|
ProtocolError(String),
|
|
}
|
|
|
|
impl fmt::Display for ImapError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
ImapError::ConnectionFailed(msg) => write!(f, "Connection failed: {msg}"),
|
|
ImapError::AuthenticationFailed => write!(f, "Authentication failed"),
|
|
ImapError::FolderNotFound(name) => write!(f, "Folder not found: {name}"),
|
|
ImapError::MessageNotFound { uid, folder } => {
|
|
write!(f, "Message UID {uid} not found in folder {folder}")
|
|
}
|
|
ImapError::ProtocolError(msg) => write!(f, "Protocol error: {msg}"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for ImapError {}
|