use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class FlowExceptionHandler method apply.
@Override
default Publisher<CoreEvent> apply(Exception exception) {
try {
if (exception instanceof MessagingException) {
MessagingException me = (MessagingException) exception;
me.setProcessedEvent(handleException(exception, me.getEvent()));
if (me.handled()) {
return just(me.getEvent());
} else {
return error(exception);
}
} else {
return error(exception);
}
} catch (Throwable throwable) {
return error(propagateWrappingFatal(throwable));
}
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class InvokerMessageProcessor method evaluateArguments.
protected Object[] evaluateArguments(CoreEvent event, List<?> argumentTemplates) throws MessagingException {
int argSize = argumentTemplates != null ? argumentTemplates.size() : 0;
Object[] args = new Object[argSize];
try {
for (int i = 0; i < args.length; i++) {
Object argumentTemplate = argumentTemplates.get(i);
if (argumentTemplate != null) {
args[i] = transformArgument(evaluateExpressionCandidate(argumentTemplate, event), argumentTypes[i]);
}
}
return args;
} catch (TransformerException e) {
throw new MessagingException(event, e, this);
}
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class OperationPolicyProcessor method executePolicyChain.
private Mono<PrivilegedEvent> executePolicyChain(PrivilegedEvent operationEvent, PolicyStateId policyStateId, PrivilegedEvent policyEvent) {
PolicyChain policyChain = policy.getPolicyChain();
policyChain.onChainError(t -> manageError(policyStateId, operationEvent, (MessagingException) t));
return just(policyEvent).doOnNext(event -> logPolicy(event.getContext().getCorrelationId(), policyStateId.getPolicyId(), getMessageAttributesAsString(event), "Before operation")).cast(CoreEvent.class).transform(policyChain).cast(PrivilegedEvent.class).doOnNext(policyChainResult -> policyStateHandler.updateState(policyStateId, policyChainResult)).map(policyChainResult -> policyEventConverter.createEvent(policyChainResult, operationEvent)).doOnNext(event -> logPolicy(event.getContext().getCorrelationId(), policyStateId.getPolicyId(), getMessageAttributesAsString(event), "After operation"));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class CompositeSourcePolicy method processNextOperation.
/**
* Executes the flow.
*
* If there's a {@link SourcePolicyParametersTransformer} provided then it will use it to convert the source response or source
* failure response from the parameters back to a {@link Message} that can be routed through the policy chain which later will
* be convert back to response or failure response parameters thus allowing the policy chain to modify the response.. That
* message will be the result of the next-operation of the policy.
*
* If no {@link SourcePolicyParametersTransformer} is provided, then the same response from the flow is going to be routed as
* response of the next-operation of the policy chain. In this case, the same response from the flow is going to be used to
* generate the response or failure response for the source so the policy chain is not going to be able to modify the response
* sent by the source.
*
* When the flow execution fails, it will create a {@link FlowExecutionException} instead of a regular
* {@link MessagingException} to signal that the failure was through the the flow exception and not the policy logic.
*/
@Override
protected Publisher<CoreEvent> processNextOperation(CoreEvent event) {
return just(event).flatMap(request -> from(processWithChildContext(request, flowExecutionProcessor, empty()))).map(flowExecutionResponse -> {
originalResponseParameters = getParametersProcessor().getSuccessfulExecutionResponseParametersFunction().apply(flowExecutionResponse);
Message message = getParametersTransformer().map(parametersTransformer -> parametersTransformer.fromSuccessResponseParametersToMessage(originalResponseParameters)).orElseGet(flowExecutionResponse::getMessage);
return CoreEvent.builder(event).message(message).build();
}).onErrorMap(MessagingException.class, messagingException -> {
originalFailureResponseParameters = getParametersProcessor().getFailedExecutionResponseParametersFunction().apply(messagingException.getEvent());
Message message = getParametersTransformer().map(parametersTransformer -> parametersTransformer.fromFailureResponseParametersToMessage(originalFailureResponseParameters)).orElse(messagingException.getEvent().getMessage());
MessagingException flowExecutionException = new FlowExecutionException(CoreEvent.builder(messagingException.getEvent()).message(message).build(), messagingException.getCause(), messagingException.getFailingComponent());
if (messagingException.getInfo().containsKey(INFO_ALREADY_LOGGED_KEY)) {
flowExecutionException.addInfo(INFO_ALREADY_LOGGED_KEY, messagingException.getInfo().get(INFO_ALREADY_LOGGED_KEY));
}
return flowExecutionException;
}).doOnError(e -> LOGGER.error(e.getMessage(), e));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class ReactiveInterceptorAdapter method createMessagingException.
protected 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);
}
Aggregations