Class SimpleExceptionHandler<E extends java.lang.Throwable>
- java.lang.Object
-
- com.github.fmjsjx.libnetty.http.server.component.SimpleExceptionHandler<E>
-
- Type Parameters:
E- the type of exception
- All Implemented Interfaces:
ExceptionHandler,HttpServerComponent
public abstract class SimpleExceptionHandler<E extends java.lang.Throwable> extends java.lang.Object implements ExceptionHandler
The abstract implementation ofExceptionHandlerwhich allows to explicit only handle a specific type of exceptions.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleExceptionHandler()protectedSimpleExceptionHandler(java.lang.Class<? extends E> type)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanacceptCause(java.lang.Throwable cause)Returnstrueif the givencauseshould be handled.java.util.Optional<java.util.concurrent.CompletionStage<HttpResult>>handle(HttpRequestContext ctx, java.lang.Throwable cause)Handles the exception.protected abstract java.util.concurrent.CompletionStage<HttpResult>handle0(HttpRequestContext ctx, E cause)Is called for each exception for typeSimpleExceptionHandler.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.fmjsjx.libnetty.http.server.component.ExceptionHandler
componentType
-
Methods inherited from interface com.github.fmjsjx.libnetty.http.server.component.HttpServerComponent
close, onServerClosed
-
-
-
-
Constructor Detail
-
SimpleExceptionHandler
protected SimpleExceptionHandler()
-
SimpleExceptionHandler
protected SimpleExceptionHandler(java.lang.Class<? extends E> type)
-
-
Method Detail
-
acceptCause
public boolean acceptCause(java.lang.Throwable cause)
Returnstrueif the givencauseshould be handled.- Parameters:
cause- the cause- Returns:
trueif the givencauseshould be handled
-
handle
public java.util.Optional<java.util.concurrent.CompletionStage<HttpResult>> handle(HttpRequestContext ctx, java.lang.Throwable cause)
Description copied from interface:ExceptionHandlerHandles the exception.- Specified by:
handlein interfaceExceptionHandler- Parameters:
ctx- theHttpRequestContextcause- the cause to handle- Returns:
- an
Optional<CompletionStage<HttpResult>>
-
handle0
protected abstract java.util.concurrent.CompletionStage<HttpResult> handle0(HttpRequestContext ctx, E cause)
Is called for each exception for typeSimpleExceptionHandler.- Parameters:
ctx- the HttpRequestContext}cause- the cause to handle- Returns:
- a
CompletionStage<HttpResult>
-
-