Package kos.core.exception
Class PredicateExceptionHandler
- java.lang.Object
-
- kos.core.exception.PredicateExceptionHandler
-
- All Implemented Interfaces:
ExceptionHandler
public class PredicateExceptionHandler extends Object implements ExceptionHandler
The default Exception Handler mechanism. It provides predicate-based semantics for Exception Handler matching.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classPredicateExceptionHandler.PredicateAndHandler
-
Field Summary
Fields Modifier and Type Field Description (package private) @NonNull List<PredicateExceptionHandler.PredicateAndHandler>predicatesAndHandlersThis is a naive implementation, which the performance degrades linearly as the number of predicates grows.
-
Constructor Summary
Constructors Constructor Description PredicateExceptionHandler()Constructs this class with an empty, but mutable, list of predicates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Predicate<Throwable> predicate, ExceptionHandler handler)Responsehandle(io.vertx.core.http.HttpServerRequest request, Throwable cause)Handles exceptions by returning aResponseobject that will be send as http response to the client.private ResponsehandleUnknownError(io.vertx.core.http.HttpServerRequest request, Throwable cause)
-
-
-
Field Detail
-
predicatesAndHandlers
@NonNull final @NonNull List<PredicateExceptionHandler.PredicateAndHandler> predicatesAndHandlers
This is a naive implementation, which the performance degrades linearly as the number of predicates grows. It might not be a problem as exceptions shouldn't be the preferred request path, thus not impacting the user experience that much.
-
-
Method Detail
-
add
public void add(Predicate<Throwable> predicate, ExceptionHandler handler)
-
handle
public Response handle(io.vertx.core.http.HttpServerRequest request, Throwable cause)
Description copied from interface:ExceptionHandlerHandles exceptions by returning aResponseobject that will be send as http response to the client.- Specified by:
handlein interfaceExceptionHandler- Parameters:
request- current request contextcause- error cause- Returns:
- object that will be send as http response to the client
- See Also:
ExceptionHandler.handle(HttpServerRequest, Throwable)
-
-