use std::borrow::Cow; #[derive(Debug, Error)] pub enum GroupError { #[error("User is admin")] UserIsAdmin, #[error("User is banned")] UserIsBanned, #[error("User opted out from the group")] UserOptedOut, #[error("Server could not be banned because there are admin users on it")] AdminsOnServer, #[error("Config error: {0}")] BadConfig(Cow<'static, str>), #[error("API request timed out")] ApiTimeout, #[error(transparent)] IoError(#[from] std::io::Error), #[error(transparent)] Serializer(#[from] serde_json::Error), #[error(transparent)] Serializer5(#[from] json5::Error), #[error(transparent)] Elefren(#[from] elefren::Error), } // this is for tests impl PartialEq for GroupError { fn eq(&self, other: &Self) -> bool { matches!( (self, other), (Self::UserIsAdmin, Self::UserIsAdmin) | (Self::UserIsBanned, Self::UserIsBanned) | (Self::AdminsOnServer, Self::AdminsOnServer) | (Self::BadConfig(_), Self::BadConfig(_)) ) } }