Module ultimategdbot.api
Class CommandErrorHandler
- java.lang.Object
-
- com.github.alex1304.ultimategdbot.api.command.CommandErrorHandler
-
public final class CommandErrorHandler extends Object
Provides a convenient way to add error handlers for bot commands.
-
-
Constructor Summary
Constructors Constructor Description CommandErrorHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Throwable>
voidaddHandler(Class<T> errorClass, BiFunction<T,Context,reactor.core.publisher.Mono<Void>> handleAction)
Adds an error handler.reactor.core.publisher.Mono<Void>
apply(reactor.core.publisher.Mono<Void> commandMono, Context ctx)
Applies the handler on the resulting Mono ofCommand.run(Context)
.String
toString()
-
-
-
Method Detail
-
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 handlerhandleAction
- 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 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.
-
-