1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
use core::fmt; use std::error::Error; #[derive(Debug, Eq, PartialEq, Clone)] pub enum MessageBuildError { UserWithoutHost, MissingCommand, } impl fmt::Display for MessageBuildError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let message = match self { MessageBuildError::UserWithoutHost => { "irc prefix can only contain a user if host is also present" } MessageBuildError::MissingCommand => "irc message requires an command", }; write!(f, "{}", message) } } impl Error for MessageBuildError {} #[derive(Debug, Eq, PartialEq, Clone)] pub enum InvalidIrcFormatError { Tag(String), NoTagEnd(String), } impl fmt::Display for InvalidIrcFormatError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { InvalidIrcFormatError::Tag(raw) => write!(f, "Invalid tags format: {}", raw), InvalidIrcFormatError::NoTagEnd(raw_message) => write!( f, "No space to end the Tag found in message: {}", raw_message ), } } } impl Error for InvalidIrcFormatError {}