Interface ChannelExceptionHandler<C extends EngineConnection>
- Type Parameters:
C
- The connection type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Channel
s. This handler
can be implemented by plugin developers.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
handle
(C connection, Channel channel, ChannelException exception, @Nullable CompletableFuture<?> future) Handles aChannelException
that occurred for a specificEngineConnection
.Gets theChannelExceptionHandler
that will always log when aChannelException
occurs.default ChannelExceptionHandler<C>
suppress
(Class<? extends ChannelException> exceptionType) Returns a newChannelExceptionHandler
that suppresses a certain type ofChannelException
to be handled through this exception handler.default ChannelExceptionHandler<C>
Returns a newChannelExceptionHandler
that suppresses everyChannelException
to be handled through this exception handler if aCompletableFuture
is applicable.default ChannelExceptionHandler<C>
suppressIfFutureIsPresent
(Class<? extends ChannelException> exceptionType) Returns a newChannelExceptionHandler
that suppressesChannelException
of the given type to be handled through this exception handler if aCompletableFuture
is applicable.
-
Method Details
-
logEverything
Gets theChannelExceptionHandler
that will always log when aChannelException
occurs.CompletableFuture
s will also receive theChannelException
s like expected.This
ChannelExceptionHandler
is useful if you don't need special handling for exceptions. This handler can be customized through the suppress methods.- Returns:
- The channel exception handler
-
handle
void handle(C connection, Channel channel, ChannelException exception, @Nullable CompletableFuture<?> future) Handles aChannelException
that occurred for a specificEngineConnection
. This includes exceptions caused by encoding or decoding payloads, handling packets, when a packet is send to an unsupported connection, etc.The
CompletableFuture
is the one that was returned by one of the send operations, this one must be completed when an exception occurs. The future is always null when a request packet is being handled on the other side.- Parameters:
connection
- The connection that the exception occurred forchannel
- The channel the exception occurred onexception
- The exception the occurredfuture
- The future of the send operation or receive operation
-
suppressAllIfFutureIsPresent
Returns a newChannelExceptionHandler
that suppresses everyChannelException
to be handled through this exception handler if aCompletableFuture
is applicable.This
ChannelExceptionHandler
is useful if you're planning to handle every exception of the returnedCompletableFuture
s.- Returns:
- The new channel exception handler
-
suppressIfFutureIsPresent
default ChannelExceptionHandler<C> suppressIfFutureIsPresent(Class<? extends ChannelException> exceptionType) Returns a newChannelExceptionHandler
that suppressesChannelException
of the given type to be handled through this exception handler if aCompletableFuture
is applicable.The returned
ChannelExceptionHandler
is useful if you're planning to handle certain exception types of the returnedCompletableFuture
s.- Parameters:
exceptionType
- The exception type to suppress- Returns:
- The new channel exception handler
-
suppress
Returns a newChannelExceptionHandler
that suppresses a certain type ofChannelException
to be handled through this exception handler. TheCompletableFuture
s will still receive the exception.This is useful to suppress certain exceptions from being logged. For example
ChannelNotSupportedException
can be suppressed if you don't want to log the exception every time you send a payload to a connection that doesn't support the channel. Then you can handle this through theCompletableFuture
s.- Parameters:
exceptionType
- The exception type to suppress- Returns:
- The new channel exception handler
-