Package kos.core.exception
Class PredicateExceptionHandler
java.lang.Object
kos.core.exception.PredicateExceptionHandler
- All Implemented Interfaces:
ExceptionHandler
The default Exception Handler mechanism. It provides predicate-based
semantics for Exception Handler matching.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final @NonNull List<PredicateExceptionHandler.PredicateAndHandler>This is a naive implementation, which the performance degrades linearly as the number of predicates grows. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs this class with an empty, but mutable, list of predicates. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Predicate<Throwable> predicate, ExceptionHandler handler) 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 Details
-
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.
-
-
Constructor Details
-
PredicateExceptionHandler
public PredicateExceptionHandler()Constructs this class with an empty, but mutable, list of predicates.
-
-
Method Details
-
add
-
handle
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:
-
handleUnknownError
-