forked from MightyPork/group-actor
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.
36 lines
1.1 KiB
36 lines
1.1 KiB
3 years ago
|
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(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 {
|
||
|
match (self, other) {
|
||
|
(Self::UserIsAdmin, Self::UserIsAdmin) => true,
|
||
|
(Self::UserIsBanned, Self::UserIsBanned) => true,
|
||
|
(Self::AdminsOnServer, Self::AdminsOnServer) => true,
|
||
|
(Self::GroupNotExist, Self::GroupNotExist) => true,
|
||
|
(Self::BadConfig(_), Self::BadConfig(_)) => true,
|
||
|
_ => false,
|
||
|
}
|
||
|
}
|
||
|
}
|