use of org.mule.runtime.api.message.Error in project mule by mulesoft.
the class AbstractForkJoinStrategyFactory method createCompositeRoutingException.
private CompositeRoutingException createCompositeRoutingException(List<CoreEvent> results) {
Map<String, Message> successMap = new LinkedHashMap<>();
Map<String, Error> errorMap = new LinkedHashMap<>();
for (CoreEvent event : results) {
String key = Integer.toString(event.getGroupCorrelation().get().getSequence());
if (event.getError().isPresent()) {
errorMap.put(key, event.getError().get());
} else {
successMap.put(key, event.getMessage());
}
}
return new CompositeRoutingException(new RoutingResult(successMap, errorMap));
}
use of org.mule.runtime.api.message.Error in project mule by mulesoft.
the class ReactiveInterceptionAction method fail.
@Override
public CompletableFuture<InterceptionEvent> fail(Throwable cause) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Called fail() for processor {} with cause {} ({})", ((Component) processor).getLocation().getLocation(), cause.getClass(), cause.getMessage());
}
Error newError = getErrorFromFailingProcessor(null, (Component) processor, cause, errorTypeLocator);
interceptionEvent.setError(newError.getErrorType(), cause);
CompletableFuture<InterceptionEvent> completableFuture = new CompletableFuture<>();
completableFuture.completeExceptionally(new MessagingException(interceptionEvent.resolve(), cause, (Component) processor));
return completableFuture;
}
use of org.mule.runtime.api.message.Error in project mule by mulesoft.
the class InternalExceptionUtils method createErrorEvent.
/**
* Create new {@link CoreEvent} with {@link org.mule.runtime.api.message.Error} instance set.
*
* @param currentEvent event when error occured.
* @param obj message processor/source.
* @param me messaging exception.
* @param locator the mule context.
* @return new {@link CoreEvent} with relevant {@link org.mule.runtime.api.message.Error} set.
*/
public static CoreEvent createErrorEvent(CoreEvent currentEvent, Component obj, MessagingException me, ErrorTypeLocator locator) {
Throwable cause = me.getCause() != null ? me.getCause() : me;
List<ErrorMapping> errorMappings = getErrorMappings(obj);
if (!errorMappings.isEmpty() || isMessagingExceptionCause(me, cause)) {
Error newError = getErrorFromFailingProcessor(currentEvent, obj, cause, locator);
CoreEvent newEvent = CoreEvent.builder(me.getEvent()).error(newError).build();
me.setProcessedEvent(newEvent);
return newEvent;
} else {
return currentEvent;
}
}
use of org.mule.runtime.api.message.Error in project mule by mulesoft.
the class CompositeRoutingException method getDetailedMessage.
@Override
public String getDetailedMessage() {
StringBuilder builder = new StringBuilder();
builder.append(MESSAGE_TITLE).append(lineSeparator());
for (Entry<String, Error> entry : routingResult.getFailures().entrySet()) {
String routeSubtitle = String.format("Route %s: ", entry.getKey());
MuleException muleException = ExceptionHelper.getRootMuleException(entry.getValue().getCause());
if (muleException != null) {
builder.append(routeSubtitle).append(muleException.getDetailedMessage());
} else {
builder.append(routeSubtitle).append("Caught exception in Exception Strategy: " + entry.getValue().getCause().getMessage());
}
}
return builder.toString();
}
use of org.mule.runtime.api.message.Error in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveExceptionWithUnknownUnderlyingError.
@Test
public void resolveExceptionWithUnknownUnderlyingError() {
Optional<Error> surfaceError = mockError(CONNECTION, null);
when(event.getError()).thenReturn(surfaceError);
MessagingException me = newMessagingException(new Exception(), event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, CONNECTION);
}
Aggregations