Browse Source

log command execution exceptions in wrapped obj

pull/2584/head
Cenngo 2 years ago
parent
commit
044a4d99b8
2 changed files with 18 additions and 0 deletions
  1. +1
    -0
      src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs
  2. +17
    -0
      src/Discord.Net.Interactions/InteractionException.cs

+ 1
- 0
src/Discord.Net.Interactions/Info/Commands/CommandInfo.cs View File

@@ -200,6 +200,7 @@ namespace Discord.Interactions
while (ex is TargetInvocationException)
ex = ex.InnerException;

var interactionException = new InteractionException(this, context, ex);
await Module.CommandService._cmdLogger.ErrorAsync(ex).ConfigureAwait(false);

var result = ExecuteResult.FromError(ex);


+ 17
- 0
src/Discord.Net.Interactions/InteractionException.cs View 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;
}
}
}

Loading…
Cancel
Save