diff options
| author | acdenisSK <[email protected]> | 2018-06-14 22:37:15 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2018-06-14 22:37:15 +0200 |
| commit | 7eac4d5fcf6c16db64e118de3d69825909979d5b (patch) | |
| tree | 0f3affea98910a7135e18893b23d4e971440ac1b /src/framework | |
| parent | Examples speak more than words (diff) | |
| download | serenity-7eac4d5fcf6c16db64e118de3d69825909979d5b.tar.xz serenity-7eac4d5fcf6c16db64e118de3d69825909979d5b.zip | |
Neaten debug once more
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/standard/mod.rs | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs index d769d02..4b5584d 100644 --- a/src/framework/standard/mod.rs +++ b/src/framework/standard/mod.rs @@ -149,10 +149,11 @@ macro_rules! command { /// An enum representing all possible fail conditions under which a command won't /// be executed. +#[derive(Debug)] pub enum DispatchError { /// When a custom function check has failed. // - // TODO: Bring back `Arc<Command>` as `CommandOptions` here somehow? + // TODO: Bring back `Arc<Command>` as `CommandOptions` in 0.6.x. CheckFailed, /// When the requested command is disabled in bot configuration. CommandDisabled(String), @@ -188,32 +189,6 @@ pub enum DispatchError { WebhookAuthor, } -use std::fmt; - -impl fmt::Debug for DispatchError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use self::DispatchError::*; - - match *self { - CheckFailed => write!(f, "DispatchError::CheckFailed"), - CommandDisabled(ref s) => f.debug_tuple("DispatchError::CommandDisabled").field(&s).finish(), - BlockedUser => write!(f, "DispatchError::BlockedUser"), - BlockedGuild => write!(f, "DispatchError::BlockedGuild"), - BlockedChannel => write!(f, "DispatchError::BlockedChannel"), - LackOfPermissions(ref perms) => f.debug_tuple("DispatchError::LackOfPermissions").field(&perms).finish(), - RateLimited(ref num) => f.debug_tuple("DispatchError::RateLimited").field(&num).finish(), - OnlyForDM => write!(f, "DispatchError::OnlyForDM"), - OnlyForOwners => write!(f, "DispatchError::OnlyForOwners"), - OnlyForGuilds => write!(f, "DispatchError::OnlyForGuilds"), - LackingRole => write!(f, "DispatchError::LackingRole"), - NotEnoughArguments { ref min, ref given } => f.debug_struct("DispatchError::NotEnoughArguments").field("min", &min).field("given", &given).finish(), - TooManyArguments { ref max, ref given } => f.debug_struct("DispatchError::TooManyArguments").field("max", &max).field("given", &given).finish(), - IgnoredBot => write!(f, "DispatchError::IgnoredBot"), - WebhookAuthor => write!(f, "DispatchError::WebhookAuthor"), - } - } -} - type DispatchErrorHook = Fn(Context, Message, DispatchError) + Send + Sync + 'static; /// A utility for easily managing dispatches to commands. @@ -1172,12 +1147,10 @@ pub enum HelpBehaviour { Nothing } +use std::fmt; + impl fmt::Display for HelpBehaviour { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - HelpBehaviour::Strike => write!(f, "HelpBehaviour::Strike"), - HelpBehaviour::Hide => write!(f, "HelpBehaviour::Hide"), - HelpBehaviour::Nothing => write!(f, "HelBehaviour::Nothing"), - } + fmt::Debug::fmt(self, f) } } |