33 lines
1.0 KiB
Rust
33 lines
1.0 KiB
Rust
use std::fmt::Display;
|
|
|
|
pub type WResult<T> = std::result::Result<T, WError>;
|
|
|
|
#[derive(Debug)]
|
|
pub enum WError {
|
|
ParseMacError(String),
|
|
NotAMac(String),
|
|
NickNotAlphanumeric(String),
|
|
NickNotMapped(String),
|
|
InvalidConfigDir(String),
|
|
ConfigDirInitError(String),
|
|
ConfigFileFormatError(String),
|
|
UdpSocketError(String),
|
|
}
|
|
|
|
impl Display for WError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
let to_write = match self {
|
|
WError::ParseMacError(s) => format!("{}", s),
|
|
WError::NotAMac(s) => format!("'{}' is not a valid MAC", s),
|
|
WError::NickNotAlphanumeric(s) => format!("{}", s),
|
|
WError::NickNotMapped(s) => format!("{}", s),
|
|
WError::InvalidConfigDir(s) => format!("{}", s),
|
|
WError::ConfigDirInitError(s) => format!("{}", s),
|
|
WError::ConfigFileFormatError(s) => format!("{}", s),
|
|
WError::UdpSocketError(s) => format!("{}", s),
|
|
};
|
|
|
|
write!(f, "{}", to_write)
|
|
}
|
|
}
|