aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-23 23:50:09 +0200
committeracdenisSK <[email protected]>2017-10-23 23:50:31 +0200
commita58de97e6089aa98f04d2cdc7312ed38a9f72b22 (patch)
treef0538ebccf6fbe212d3f279c79d8e44e7934322b /src/framework
parentProperly update emojis, fix shard retries, fix cs (diff)
downloadserenity-a58de97e6089aa98f04d2cdc7312ed38a9f72b22.tar.xz
serenity-a58de97e6089aa98f04d2cdc7312ed38a9f72b22.zip
Add a debug impl for `DispatchError`
Why this was hand-made instead of derived is because of `CheckFailed`'s content, which is mostly `Command` not also deriving `Debug`; except that even `Command` has a trouble maker that would force us to do this hand-made anyway, `checks`. Fixes #204
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/standard/mod.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs
index 947a885..1a7a5ee 100644
--- a/src/framework/standard/mod.rs
+++ b/src/framework/standard/mod.rs
@@ -138,6 +138,31 @@ 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"),
+ 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.