use std::fmt; #[derive(Debug)] pub enum ServerError { Io(std::io::Error), InvalidPath(String), InvalidConfiguration(String), TlsConfiguration(String), ServerStartup(String), } impl fmt::Display for ServerError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ServerError::Io(err) => write!(f, "I/O error: {}", err), ServerError::InvalidPath(path) => write!(f, "Invalid path: {}", path), ServerError::InvalidConfiguration(msg) => write!(f, "Configuration error: {}", msg), ServerError::TlsConfiguration(msg) => write!(f, "TLS configuration error: {}", msg), ServerError::ServerStartup(msg) => write!(f, "Server startup error: {}", msg), } } } impl std::error::Error for ServerError {} impl From for ServerError { fn from(err: std::io::Error) -> Self { ServerError::Io(err) } } impl From for ServerError { fn from(err: gurt::GurtError) -> Self { ServerError::ServerStartup(err.to_string()) } } pub type Result = std::result::Result;