Class ExceptionMapper<H>
java.lang.Object
net.tangly.commons.lang.exceptions.ExceptionMapper<H>
- Type Parameters:
H
- handler used to process the exception
The exception mapper processes an exception and executes associated instructions with the helper. For example, an HTTP error code and answer can be generated
based on the kind of the exception.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isRegistered
(Class<? extends Exception> clazz) Return true if the exception class is registered.void
Process the exception by executing the associated functor.void
Register the class exception with the associated consumer.void
unregister
(Class<? extends Exception> clazz) The class exception cannot be unregistered to insure we are always handling any exception.
-
Constructor Details
-
ExceptionMapper
public ExceptionMapper()
-
-
Method Details
-
register
public void register(@NotNull @NotNull Class<? extends Exception> clazz, @NotNull @NotNull BiConsumer<H, Exception> functor) Register the class exception with the associated consumer.- Parameters:
clazz
- class of the exception top bindfunctor
- consumer used to process the exception
-
unregister
-
isRegistered
-
process
Process the exception by executing the associated functor. The functor is associated with the class of the exception. Generalization of the exception class for handling is similar to the rules of the try catch instruction.- Parameters:
handler
- handler used to process the exceptionexception
- exception to be processed
-