Search in sources :

Example 1 with ExceptionPayload

use of org.mule.runtime.core.api.message.ExceptionPayload in project mule by mulesoft.

the class AbstractSystemExceptionStrategy method handleException.

@Override
public void handleException(Exception ex, RollbackSourceCallback rollbackMethod) {
    fireNotification(ex, getCurrentEvent());
    resolveAndLogException(ex);
    logger.debug("Rolling back transaction");
    rollback(ex, rollbackMethod);
    ExceptionPayload exceptionPayload = new DefaultExceptionPayload(ex);
    if (getCurrentEvent() != null) {
        PrivilegedEvent currentEvent = getCurrentEvent();
        currentEvent = PrivilegedEvent.builder(currentEvent).message(InternalMessage.builder(currentEvent.getMessage()).exceptionPayload(exceptionPayload).build()).build();
        setCurrentEvent(currentEvent);
    }
    if (ex instanceof ConnectException) {
        ((ConnectException) ex).handleReconnection(retryScheduler);
    }
}
Also used : DefaultExceptionPayload(org.mule.runtime.core.internal.message.DefaultExceptionPayload) PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) DefaultExceptionPayload(org.mule.runtime.core.internal.message.DefaultExceptionPayload) ExceptionPayload(org.mule.runtime.core.api.message.ExceptionPayload) ConnectException(org.mule.runtime.core.api.connector.ConnectException)

Example 2 with ExceptionPayload

use of org.mule.runtime.core.api.message.ExceptionPayload in project mule by mulesoft.

the class TestLegacyMessageUtils method getExceptionPayload.

/**
 * If an error occurred during the processing of this message this will return a ErrorPayload that contains the root exception
 * and Mule error code, plus any other related info
 *
 * @param message message used to obtain the data from. Must be a {@link InternalMessage}
 * @return The exception payload (if any) attached to this message
 * @throws {@link IllegalStateException} if there is any problem accessing the legacy message API using reflection
 */
public static ExceptionPayload getExceptionPayload(Message message) {
    try {
        Method method = message.getClass().getMethod("getExceptionPayload");
        method.setAccessible(true);
        return (ExceptionPayload) method.invoke(message);
    } catch (Exception e) {
        throw new IllegalStateException(LEGACY_MESSAGE_API_ERROR, e);
    }
}
Also used : ExceptionPayload(org.mule.runtime.core.api.message.ExceptionPayload) Method(java.lang.reflect.Method)

Aggregations

ExceptionPayload (org.mule.runtime.core.api.message.ExceptionPayload)2 Method (java.lang.reflect.Method)1 ConnectException (org.mule.runtime.core.api.connector.ConnectException)1 DefaultExceptionPayload (org.mule.runtime.core.internal.message.DefaultExceptionPayload)1 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)1