Files
RustBox/src/sieve/error.rs
T
2026-10-31 14:36:07 +01:00

38 lines
1.3 KiB
Rust

use std::fmt;
#[derive(Debug)]
pub enum SieveError {
ConnectionFailed(String),
TlsFailed(String),
AuthenticationFailed(String),
InsecureAuthenticationBlocked,
Protocol(String),
ServerRejected(String),
Timeout,
ScriptTooLarge,
}
impl fmt::Display for SieveError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ConnectionFailed(msg) => write!(f, "ManageSieve connection failed: {msg}"),
Self::TlsFailed(msg) => write!(f, "ManageSieve TLS failed: {msg}"),
Self::AuthenticationFailed(msg) => {
write!(f, "ManageSieve authentication failed: {msg}")
}
Self::InsecureAuthenticationBlocked => write!(
f,
"ManageSieve plaintext authentication is blocked; use STARTTLS/implicit TLS or explicitly enable SIEVE_ALLOW_INSECURE_AUTH"
),
Self::Protocol(msg) => write!(f, "ManageSieve protocol error: {msg}"),
Self::ServerRejected(msg) => {
write!(f, "ManageSieve server rejected the command: {msg}")
}
Self::Timeout => write!(f, "ManageSieve operation timed out"),
Self::ScriptTooLarge => write!(f, "Sieve script exceeds the RustBox 0.2.0 size limit"),
}
}
}
impl std::error::Error for SieveError {}