Class ExceptionHandler
java.lang.Object
org.mule.runtime.extension.api.runtime.exception.ExceptionHandler
Allows the developer to provide generic logic to enrich exceptions, either via logging, sending notifications, etc.
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.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ExceptionThis method can return a new enriched exception or the original exception after doing some processing with it.getCauseOfType(Throwable throwable, Class<T> causeType) Returns the first cause ofthrowablewhich is an instance ofcauseType.protected ExceptiongetRootErrorException(Exception exception) This method instrospects the givenexceptionlooking for the deepestErrorTypeDefinitionin the causes.
-
Constructor Details
-
ExceptionHandler
public ExceptionHandler()
-
-
Method Details
-
enrichException
This method can return a new enriched exception or the original exception after doing some processing with it. It must not return a null value. Also the implementation of this method needs to be thread safe and must not fail.- Parameters:
e- the exception thrown by the operation- Returns:
- an Enriched Exception
- Since:
- 1.0
-
getRootErrorException
This method instrospects the givenexceptionlooking for the deepestErrorTypeDefinitionin the causes. Returns a a newModuleExceptionthat wraps the exception received as parameter with theErrorTypeDefinitionfound.- Parameters:
exception- to introspect- Returns:
ModuleExceptionwith the innermostErrorTypeDefinitionfound.
-
getCauseOfType
Returns the first cause ofthrowablewhich is an instance ofcauseType. Ifthrowableis an instance ofcauseTypeitself, thenthrowableis returned.- Type Parameters:
T- the generic type of the expected exception- Parameters:
throwable- the exception to introspectcauseType- the cause type- Returns:
- an optional cause
-