Class CommandErrorHandler


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

      • CommandErrorHandler

        public CommandErrorHandler()
    • Method Detail

      • addHandler

        public <T extends Throwable> void addHandler​(Class<T> errorClass,
                                                     java.util.function.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.execute(Context).
        Parameters:
        commandMono - the Mono returned by Command.execute(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.