Class CommandExceptionHandler
java.lang.Object
eu.cloudnetservice.node.impl.command.exception.CommandExceptionHandler
This exception handler provides a default handling of exceptions that can occur on command execution.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final eu.cloudnetservice.node.command.CommandProviderprivate final eu.cloudnetservice.driver.event.EventManagerprivate final eu.cloudnetservice.driver.language.I18nprivate static final org.slf4j.Logger -
Constructor Summary
ConstructorsConstructorDescriptionCommandExceptionHandler(@NonNull eu.cloudnetservice.driver.language.I18n i18n, @NonNull eu.cloudnetservice.node.command.CommandProvider commandProvider, @NonNull eu.cloudnetservice.driver.event.EventManager eventManager) -
Method Summary
Modifier and TypeMethodDescriptioncollectCommandHelp(@NonNull List<CommandComponent<?>> currentChain) Collects the default command help for the given command chain.protected voidcollectDefaultUsage(@NonNull List<String> collector, @NonNull eu.cloudnetservice.driver.command.CommandInfo commandInfo) Formats and collects the default command usage for the give command info.voidhandleCommandExceptions(@NonNull eu.cloudnetservice.node.command.source.CommandSource source, @Nullable Throwable cause) Handles occurring exceptions when executing a command and waiting for the result of the future.
-
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
-
-
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.
-