use std::error::Error as StdError;
use std::fmt::{Display, Formatter, Result as FmtResult};
use super::Permissions;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum Error {
BulkDeleteAmount,
DeleteMessageDaysAmount(u8),
EmbedTooLarge(u64),
GuildNotFound,
InvalidPermissions(Permissions),
InvalidUser,
ItemMissing,
MessageTooLong(u64),
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
f.write_str(self.description())
}
}
impl StdError for Error {
fn description(&self) -> &str {
match *self {
Error::BulkDeleteAmount => "Too few/many messages to bulk delete",
Error::DeleteMessageDaysAmount(_) => "Invalid delete message days",
Error::EmbedTooLarge(_) => "Embed too large",
Error::GuildNotFound => "Guild not found in the cache",
Error::InvalidPermissions(_) => "Invalid permissions",
Error::InvalidUser => "The current user can not perform the action",
Error::ItemMissing => "The required item is missing from the cache",
Error::MessageTooLong(_) => "Message too large",
}
}
}