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>
voidaddHandler(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 ofCommand.run(Context).java.lang.StringtoString()
-
Constructor Details
-
CommandErrorHandler
public CommandErrorHandler()
-
-
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 handlerhandleAction- 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 ofCommand.run(Context).- Parameters:
commandMono- the Mono returned byCommand.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:
toStringin classjava.lang.Object
-