Class CommandErrorHandler

java.lang.Object
com.github.alex1304.ultimategdbot.api.command.CommandErrorHandler

public class CommandErrorHandler
extends Object
Provides a convenient way to add error handlers for bot commands.
  • Constructor Details

  • Method Details

    • addHandler

      public <T extends Throwable> void addHandler​(Class<T> errorClass, BiFunction<T,​Context,​reactor.core.publisher.Mono<Void>> handleAction)
      Adds an error handler.
      Type Parameters:
      T - the type of error to handle
      Parameters:
      errorClass - the type of error to handler
      handleAction - the action to execute according to the error instance and the context
    • apply

      public reactor.core.publisher.Mono<Void> apply​(reactor.core.publisher.Mono<Void> commandMono, Context ctx)
      Applies the handler on the resulting Mono of Command.run(Context).
      Parameters:
      commandMono - the Mono returned by Command.run(Context)
      ctx - the context in which the command was used
      Returns:
      a new Mono<Void> identical to the given commandMono but with the error handlers applied.
    • toString

      public String toString()
      Overrides:
      toString in class Object