| @@ -201,7 +201,9 @@ namespace Discord.Commands | |||||
| { | { | ||||
| var instance = createInstance(services); | var instance = createInstance(services); | ||||
| instance.SetContext(context); | instance.SetContext(context); | ||||
| Exception exc = null; | |||||
| try | try | ||||
| { | { | ||||
| instance.BeforeExecute(cmd); | instance.BeforeExecute(cmd); | ||||
| @@ -217,9 +219,14 @@ namespace Discord.Commands | |||||
| return ExecuteResult.FromSuccess(); | return ExecuteResult.FromSuccess(); | ||||
| } | } | ||||
| } | } | ||||
| catch (Exception exception) | |||||
| { | |||||
| exc = exception; | |||||
| throw; | |||||
| } | |||||
| finally | finally | ||||
| { | { | ||||
| instance.AfterExecute(cmd); | |||||
| instance.AfterExecute(cmd, exc); | |||||
| (instance as IDisposable)?.Dispose(); | (instance as IDisposable)?.Dispose(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,4 +1,6 @@ | |||||
| namespace Discord.Commands | |||||
| using System; | |||||
| namespace Discord.Commands | |||||
| { | { | ||||
| internal interface IModuleBase | internal interface IModuleBase | ||||
| { | { | ||||
| @@ -6,6 +8,6 @@ | |||||
| void BeforeExecute(CommandInfo command); | void BeforeExecute(CommandInfo command); | ||||
| void AfterExecute(CommandInfo command); | |||||
| void AfterExecute(CommandInfo command, Exception exception); | |||||
| } | } | ||||
| } | } | ||||
| @@ -19,7 +19,7 @@ namespace Discord.Commands | |||||
| { | { | ||||
| } | } | ||||
| protected virtual void AfterExecute(CommandInfo command) | |||||
| protected virtual void AfterExecute(CommandInfo command, Exception exception) | |||||
| { | { | ||||
| } | } | ||||
| @@ -32,6 +32,6 @@ namespace Discord.Commands | |||||
| void IModuleBase.BeforeExecute(CommandInfo command) => BeforeExecute(command); | void IModuleBase.BeforeExecute(CommandInfo command) => BeforeExecute(command); | ||||
| void IModuleBase.AfterExecute(CommandInfo command) => AfterExecute(command); | |||||
| void IModuleBase.AfterExecute(CommandInfo command, Exception exception) => AfterExecute(command, exception); | |||||
| } | } | ||||
| } | } | ||||