Log InteractionCommand execution exceptions in Wrapped Exception (#2584)
* log command execution exceptions in wrapped obj * actually log the wrapped exception --------- Co-authored-by: Misha133 <mihagribkov133@gmail.com>
This commit is contained in:
@@ -413,8 +413,9 @@ namespace Discord.Interactions.Builders
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await commandService._cmdLogger.ErrorAsync(ex).ConfigureAwait(false);
|
var interactionException = new InteractionException(commandInfo, context, ex);
|
||||||
return ExecuteResult.FromError(ex);
|
await commandService._cmdLogger.ErrorAsync(interactionException).ConfigureAwait(false);
|
||||||
|
return ExecuteResult.FromError(interactionException);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -165,7 +165,8 @@ namespace Discord.Interactions
|
|||||||
while (ex is TargetInvocationException)
|
while (ex is TargetInvocationException)
|
||||||
ex = ex.InnerException;
|
ex = ex.InnerException;
|
||||||
|
|
||||||
await Module.CommandService._cmdLogger.ErrorAsync(ex).ConfigureAwait(false);
|
var interactionException = new InteractionException(this, context, ex);
|
||||||
|
await Module.CommandService._cmdLogger.ErrorAsync(interactionException).ConfigureAwait(false);
|
||||||
|
|
||||||
var result = ExecuteResult.FromError(ex);
|
var result = ExecuteResult.FromError(ex);
|
||||||
await InvokeModuleEvent(context, result).ConfigureAwait(false);
|
await InvokeModuleEvent(context, result).ConfigureAwait(false);
|
||||||
|
|||||||
17
src/Discord.Net.Interactions/InteractionException.cs
Normal file
17
src/Discord.Net.Interactions/InteractionException.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Discord.Interactions
|
||||||
|
{
|
||||||
|
public class InteractionException : Exception
|
||||||
|
{
|
||||||
|
public ICommandInfo CommandInfo { get; }
|
||||||
|
public IInteractionContext InteractionContext { get; }
|
||||||
|
|
||||||
|
public InteractionException(ICommandInfo commandInfo, IInteractionContext context, Exception exception)
|
||||||
|
: base($"Error occurred executing {commandInfo}.", exception)
|
||||||
|
{
|
||||||
|
CommandInfo = commandInfo;
|
||||||
|
InteractionContext = context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user