Class CommandErrorHandler

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

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

    Constructors 
    Constructor Description
    CommandErrorHandler()  
  • Method Summary

    Modifier and Type Method Description
    <T extends java.lang.Throwable>
    void
    addHandler​(java.lang.Class<T> errorClass, java.util.function.BiFunction<T,​Context,​reactor.core.publisher.Mono<java.lang.Void>> handleAction)
    Adds an error handler.
    reactor.core.publisher.Mono<java.lang.Void> apply​(reactor.core.publisher.Mono<java.lang.Void> commandMono, Context ctx)
    Applies the handler on the resulting Mono of Command.run(Context).
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • addHandler

      public <T extends java.lang.Throwable> void addHandler​(java.lang.Class<T> errorClass, java.util.function.BiFunction<T,​Context,​reactor.core.publisher.Mono<java.lang.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<java.lang.Void> apply​(reactor.core.publisher.Mono<java.lang.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 java.lang.String toString()
      Overrides:
      toString in class java.lang.Object