Split to crates
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user