diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-30 15:24:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-30 15:24:46 +0200 |
| commit | 795e46c98616801c678bd0a403b08cb0fcd5ee43 (patch) | |
| tree | 040efd79def19e28422980ebfb6ce414ff349570 /mumlib/src | |
| parent | a6d433e3ad95b9a21d5d473da4b1f65e78585bb2 (diff) | |
| parent | b52068eade50758673e29c79e7cb8be3f1b4151f (diff) | |
| download | mum-795e46c98616801c678bd0a403b08cb0fcd5ee43.tar.gz | |
Merge pull request #79 from mum-rs/tcp-event-queue
Diffstat (limited to 'mumlib/src')
| -rw-r--r-- | mumlib/src/error.rs | 22 | ||||
| -rw-r--r-- | mumlib/src/lib.rs | 2 |
2 files changed, 14 insertions, 10 deletions
diff --git a/mumlib/src/error.rs b/mumlib/src/error.rs index 8c66068..f6a02a7 100644 --- a/mumlib/src/error.rs +++ b/mumlib/src/error.rs @@ -3,30 +3,32 @@ use std::fmt; pub type Result<T> = std::result::Result<T, Error>; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub enum Error { - DisconnectedError, - AlreadyConnectedError, + Disconnected, + AlreadyConnected, ChannelIdentifierError(String, ChannelIdentifierError), - InvalidServerAddrError(String, u16), - InvalidUsernameError(String), + InvalidServerAddr(String, u16), + InvalidUsername(String), + InvalidServerPassword, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Error::DisconnectedError => write!(f, "Not connected to a server"), - Error::AlreadyConnectedError => write!(f, "Already connected to a server"), + Error::Disconnected=> write!(f, "Not connected to a server"), + Error::AlreadyConnected=> write!(f, "Already connected to a server"), Error::ChannelIdentifierError(id, kind) => write!(f, "{}: {}", kind, id), - Error::InvalidServerAddrError(addr, port) => { + Error::InvalidServerAddr(addr, port) => { write!(f, "Invalid server address: {}: {}", addr, port) } - Error::InvalidUsernameError(username) => write!(f, "Invalid username: {}", username), + Error::InvalidUsername(username) => write!(f, "Invalid username: {}", username), + Error::InvalidServerPassword => write!(f, "Invalid server password") } } } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum ChannelIdentifierError { Invalid, Ambiguous, diff --git a/mumlib/src/lib.rs b/mumlib/src/lib.rs index bccf073..36edc10 100644 --- a/mumlib/src/lib.rs +++ b/mumlib/src/lib.rs @@ -3,6 +3,8 @@ pub mod config; pub mod error; pub mod state; +pub use error::Error; + use colored::*; use log::*; |
