Class CommandExceptionHandler

java.lang.Object
eu.cloudnetservice.node.impl.command.exception.CommandExceptionHandler

@Singleton public class CommandExceptionHandler extends Object
This exception handler provides a default handling of exceptions that can occur on command execution.
Since:
4.0
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • i18n

      private final eu.cloudnetservice.driver.language.I18n i18n
    • commandProvider

      private final eu.cloudnetservice.node.command.CommandProvider commandProvider
    • eventManager

      private final eu.cloudnetservice.driver.event.EventManager eventManager
  • Constructor Details

    • CommandExceptionHandler

      @Inject public CommandExceptionHandler(@NonNull @Service @NonNull eu.cloudnetservice.driver.language.I18n i18n, @NonNull @NonNull eu.cloudnetservice.node.command.CommandProvider commandProvider, @NonNull @NonNull eu.cloudnetservice.driver.event.EventManager eventManager)
  • Method Details

    • handleCommandExceptions

      public void handleCommandExceptions(@NonNull @NonNull eu.cloudnetservice.node.command.source.CommandSource source, @Nullable @Nullable Throwable cause)
      Handles occurring exceptions when executing a command and waiting for the result of the future. All relevant exceptions are handled, other exceptions are printed into the console.
      Parameters:
      source - the source of the command.
      cause - the exception that occurred during the execution.
      Throws:
      NullPointerException - if source is null.
    • collectCommandHelp

      @NonNull protected @NonNull List<String> collectCommandHelp(@NonNull @NonNull List<CommandComponent<?>> currentChain)
      Collects the default command help for the given command chain.
      Parameters:
      currentChain - the current chain of entered commands.
      Returns:
      a list containing the response for the source.
      Throws:
      NullPointerException - if the current chain is null.
    • collectDefaultUsage

      protected void collectDefaultUsage(@NonNull @NonNull List<String> collector, @NonNull @NonNull eu.cloudnetservice.driver.command.CommandInfo commandInfo)
      Formats and collects the default command usage for the give command info.
      Parameters:
      collector - the list to collect the messages to.
      commandInfo - the command to print the usage for.
      Throws:
      NullPointerException - if collector or commandInfo is null.