use std::{
error::Error as StdError,
fmt::{
Display,
Formatter,
Result as FmtResult
}
};
use super::Permissions;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum Error {
BulkDeleteAmount,
DeleteMessageDaysAmount(u8),
EmbedTooLarge(u64),
GuildNotFound,
RoleNotFound,
Hierarchy,
InvalidPermissions(Permissions),
InvalidUser,
ItemMissing,
MessageTooLong(u64),
MessagingBot,
InvalidChannelType,
NameTooShort,
NameTooLong,
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
match self {
Error::BulkDeleteAmount => f.write_str("Too few/many messages to bulk delete."),
Error::DeleteMessageDaysAmount(_) => f.write_str("Invalid delete message days."),
Error::EmbedTooLarge(_) => f.write_str("Embed too large."),
Error::GuildNotFound => f.write_str("Guild not found in the cache."),
Error::RoleNotFound => f.write_str("Role not found in the cache."),
Error::Hierarchy => f.write_str("Role hierarchy prevents this action."),
Error::InvalidChannelType => f.write_str("The channel cannot perform the action."),
Error::InvalidPermissions(_) => f.write_str("Invalid permissions."),
Error::InvalidUser => f.write_str("The current user cannot perform the action."),
Error::ItemMissing => f.write_str("The required item is missing from the cache."),
Error::MessageTooLong(_) => f.write_str("Message too large."),
Error::MessagingBot => f.write_str("Attempted to message another bot user."),
Error::NameTooShort => f.write_str("Name is under the character limit."),
Error::NameTooLong => f.write_str("Name is over the character limit."),
}
}
}
impl StdError for Error {}