2021-08-22 09:51:08 +00:00
|
|
|
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>),
|
2021-08-26 20:11:20 +00:00
|
|
|
#[error("API request timed out")]
|
|
|
|
ApiTimeout,
|
2021-08-22 09:51:08 +00:00
|
|
|
#[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 {
|
2021-08-22 16:55:06 +00:00
|
|
|
matches!(
|
|
|
|
(self, other),
|
|
|
|
(Self::UserIsAdmin, Self::UserIsAdmin)
|
|
|
|
| (Self::UserIsBanned, Self::UserIsBanned)
|
|
|
|
| (Self::AdminsOnServer, Self::AdminsOnServer)
|
|
|
|
| (Self::GroupNotExist, Self::GroupNotExist)
|
|
|
|
| (Self::BadConfig(_), Self::BadConfig(_))
|
|
|
|
)
|
2021-08-22 09:51:08 +00:00
|
|
|
}
|
|
|
|
}
|