public abstract class ExceptionHandler extends Object
The developer can return a new exception which replaces the original one or return the one that was thrown by the operation. For example, wrapping the Exception into a ConnectionException, the runtime know that reconnection is needed. Notice that this implies that the method should not fail by any reason.
Constructor and Description |
---|
ExceptionHandler() |
Modifier and Type | Method and Description |
---|---|
abstract Exception |
enrichException(Exception e)
This method can return a new enriched exception or the original exception
after doing some processing with it.
|
protected <T extends Throwable> |
getCauseOfType(Throwable throwable,
Class<T> causeType)
Returns the first cause of
throwable which is an instance of causeType . |
protected Exception |
getRootErrorException(Exception exception)
This method instrospects the given
exception looking for the deepest ErrorTypeDefinition in the causes. |
public abstract Exception enrichException(Exception e)
e
- the exception thrown by the operationprotected Exception getRootErrorException(Exception exception)
exception
looking for the deepest ErrorTypeDefinition
in the causes.
Returns a a new ModuleException
that wraps the exception received as parameter with the ErrorTypeDefinition
found.exception
- to introspectModuleException
with the innermost ErrorTypeDefinition
found.protected <T extends Throwable> Optional<T> getCauseOfType(Throwable throwable, Class<T> causeType)
throwable
which is an instance of causeType
.
If throwable
is an instance of causeType
itself, then throwable
is returned.T
- the generic type of the expected exceptionthrowable
- the exception to introspectcauseType
- the cause typeCopyright © 2018. All rights reserved.