You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandException.cs 1.3 kB

123456789101112131415161718192021222324252627282930
  1. using System;
  2. namespace Discord.Commands
  3. {
  4. /// <summary>
  5. /// The exception that is thrown if another exception occurs during a command execution.
  6. /// </summary>
  7. public class CommandException : Exception
  8. {
  9. /// <summary> Gets the command that caused the exception. </summary>
  10. public CommandInfo Command { get; }
  11. /// <summary> Gets the command context of the exception. </summary>
  12. public ICommandContext Context { get; }
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="CommandException" /> class using a
  15. /// <paramref name="command"/> information, a <paramref name="command"/> context, and the exception that
  16. /// interrupted the execution.
  17. /// </summary>
  18. /// <param name="command">The command information.</param>
  19. /// <param name="context">The context of the command.</param>
  20. /// <param name="ex">The exception that interrupted the command execution.</param>
  21. public CommandException(CommandInfo command, ICommandContext context, Exception ex)
  22. : base($"Error occurred executing {command.GetLogText(context)}.", ex)
  23. {
  24. Command = command;
  25. Context = context;
  26. }
  27. }
  28. }