use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class ReactiveInterceptionAction method fail.
@Override
public CompletableFuture<InterceptionEvent> fail(ErrorType errorType) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Called fail() for processor {} with errorType {}", ((Component) processor).getLocation().getLocation(), errorType.getIdentifier());
}
Throwable cause = new InterceptionException("");
interceptionEvent.setError(errorType, cause);
CompletableFuture<InterceptionEvent> completableFuture = new CompletableFuture<>();
completableFuture.completeExceptionally(new MessagingException(interceptionEvent.resolve(), cause, (Component) processor));
return completableFuture;
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class AbstractExceptionListener method fireNotification.
protected void fireNotification(Exception ex, CoreEvent event) {
if (enableNotifications) {
if (ex.getCause() != null && getCause(ex) instanceof SecurityException) {
fireNotification(new SecurityNotification((SecurityException) getCause(ex), SECURITY_AUTHENTICATION_FAILED));
} else {
Component component = null;
if (ex instanceof MessagingException) {
component = ((MessagingException) ex).getFailingComponent();
}
fireNotification(new ExceptionNotification(createInfo(event, ex, component), getLocation()));
}
}
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class AbstractExecutableComponent method execute.
@Override
public final CompletableFuture<Event> execute(Event event) {
CoreEvent internalEvent;
BaseEventContext child = createChildEventContext(event.getContext());
if (event instanceof CoreEvent) {
internalEvent = builder(child, (CoreEvent) event).build();
} else {
internalEvent = CoreEvent.builder(createEventContext(null)).message(event.getMessage()).error(event.getError().orElse(null)).variables(event.getVariables()).build();
}
return from(MessageProcessors.process(internalEvent, getExecutableFunction())).onErrorMap(throwable -> {
MessagingException messagingException = (MessagingException) throwable;
CoreEvent messagingExceptionEvent = messagingException.getEvent();
return new ComponentExecutionException(messagingExceptionEvent.getError().get().getCause(), messagingExceptionEvent);
}).map(r -> builder(event.getContext(), r).build()).cast(Event.class).toFuture();
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class IdempotentRedeliveryPolicy method createMessagingException.
private MessagingException createMessagingException(CoreEvent event, Throwable cause, Component processor) {
MessagingExceptionResolver exceptionResolver = new MessagingExceptionResolver(processor);
MessagingException me = new MessagingException(event, cause, processor);
return exceptionResolver.resolve(me, muleContext);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class ExtensionSourceExceptionCallback method onException.
/**
* Invokes {@link ResponseCompletionCallback#responseSentWithFailure(MessagingException, CoreEvent)} over the
* {@link #completionCallback}, using the {@code exception} and {@link #event}
*
* @param exception a {@link Throwable}
* @return a response {@link CoreEvent}
*/
@Override
public void onException(Throwable exception) {
MessagingException messagingException = exception instanceof MessagingException ? (MessagingException) exception : new MessagingException(event, exception);
CoreEvent errorEvent = createErrorEvent(event, messageProcessorContext.getMessageSource(), messagingException, messageProcessorContext.getErrorTypeLocator());
messagingException.setProcessedEvent(errorEvent);
CoreEvent errorHandlingEvent = completionCallback.responseSentWithFailure(messagingException, errorEvent);
messagingException.setProcessedEvent(errorHandlingEvent);
errorResponseHandler.accept(messagingException);
}
Aggregations