You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
group-actor/src/error.rs

38 lines
1.1 KiB

use std::borrow::Cow;
#[derive(Debug, Error)]
pub enum GroupError {
#[error("User is admin")]
UserIsAdmin,
#[error("User is banned")]
UserIsBanned,
#[error("Server could not be banned because there are admin users on it")]
AdminsOnServer,
#[error("Group config is missing in the config store")]
GroupNotExist,
#[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)]
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::GroupNotExist, Self::GroupNotExist)
| (Self::BadConfig(_), Self::BadConfig(_))
)
}
}