Search in sources :

Example 46 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class AbstractAsyncRequestReplyRequester method retrieveEvent.

private PrivilegedEvent retrieveEvent(String correlationId) throws MuleException {
    MultipleRequestReplierEvent multipleEvent = (MultipleRequestReplierEvent) store.retrieve(correlationId);
    PrivilegedEvent event = multipleEvent.getEvent();
    // TODO MULE-10302 remove this.
    if (currentMuleContext.get() == null) {
        try {
            DeserializationPostInitialisable.Implementation.init(event, muleContext);
        } catch (Exception e) {
            throw new DefaultMuleException(e);
        }
    }
    return event;
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) ResponseTimeoutException(org.mule.runtime.core.privileged.routing.ResponseTimeoutException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) RegistrationException(org.mule.runtime.core.privileged.registry.RegistrationException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException)

Example 47 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class AbstractExceptionListener method resolveExceptionAndMessageToLog.

protected Pair<MuleException, String> resolveExceptionAndMessageToLog(Throwable t) {
    MuleException muleException = getRootMuleException(t);
    String logMessage = null;
    if (muleException != null) {
        if (!isVerboseExceptions() && t instanceof EventProcessingException && ((EventProcessingException) t).getEvent().getError().map(e -> CORE_NAMESPACE_NAME.equals(e.getErrorType().getNamespace()) && UNKNOWN_ERROR_IDENTIFIER.equals(e.getErrorType().getIdentifier())).orElse(false)) {
            logMessage = ((MuleException) sanitize(muleException)).getVerboseMessage();
        } else {
            logMessage = muleException.getDetailedMessage();
        }
    }
    return new Pair<>(muleException, logMessage);
}
Also used : StringUtils.defaultString(org.apache.commons.lang3.StringUtils.defaultString) MuleException(org.mule.runtime.api.exception.MuleException) ExceptionHelper.getRootMuleException(org.mule.runtime.api.exception.ExceptionHelper.getRootMuleException) Pair(org.mule.runtime.api.util.Pair)

Example 48 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class AbstractMessageProcessorChain method start.

@Override
public void start() throws MuleException {
    List<Processor> startedProcessors = new ArrayList<>();
    try {
        for (Processor processor : getMessageProcessorsForLifecycle()) {
            if (processor instanceof Startable) {
                ((Startable) processor).start();
                startedProcessors.add(processor);
            }
        }
    } catch (MuleException e) {
        stopIfNeeded(getMessageProcessorsForLifecycle());
        throw e;
    }
}
Also used : Startable(org.mule.runtime.api.lifecycle.Startable) InterceptedReactiveProcessor(org.mule.runtime.core.internal.processor.chain.InterceptedReactiveProcessor) ReactiveProcessor(org.mule.runtime.core.api.processor.ReactiveProcessor) Processor(org.mule.runtime.core.api.processor.Processor) ArrayList(java.util.ArrayList) MuleException(org.mule.runtime.api.exception.MuleException)

Example 49 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class AbstractMessageProcessorChain method initialise.

@Override
public void initialise() throws InitialisationException {
    processorInterceptorManager.getInterceptorFactories().stream().forEach(interceptorFactory -> {
        ReactiveInterceptorAdapter reactiveInterceptorAdapter = new ReactiveInterceptorAdapter(interceptorFactory);
        try {
            muleContext.getInjector().inject(reactiveInterceptorAdapter);
        } catch (MuleException e) {
            throw new MuleRuntimeException(e);
        }
        additionalInterceptors.add(0, reactiveInterceptorAdapter);
    });
    processorInterceptorManager.getInterceptorFactories().stream().forEach(interceptorFactory -> {
        ReactiveAroundInterceptorAdapter reactiveInterceptorAdapter = new ReactiveAroundInterceptorAdapter(interceptorFactory);
        try {
            muleContext.getInjector().inject(reactiveInterceptorAdapter);
        } catch (MuleException e) {
            throw new MuleRuntimeException(e);
        }
        additionalInterceptors.add(0, reactiveInterceptorAdapter);
    });
    initialiseIfNeeded(getMessageProcessorsForLifecycle(), muleContext);
}
Also used : MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ReactiveInterceptorAdapter(org.mule.runtime.core.internal.processor.interceptor.ReactiveInterceptorAdapter) ReactiveAroundInterceptorAdapter(org.mule.runtime.core.internal.processor.interceptor.ReactiveAroundInterceptorAdapter) MuleException(org.mule.runtime.api.exception.MuleException)

Example 50 with MuleException

use of org.mule.runtime.api.exception.MuleException 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();
}
Also used : Error(org.mule.runtime.api.message.Error) MuleException(org.mule.runtime.api.exception.MuleException)

Aggregations

MuleException (org.mule.runtime.api.exception.MuleException)68 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)21 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)19 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)19 Test (org.junit.Test)15 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)14 Processor (org.mule.runtime.core.api.processor.Processor)12 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)9 Logger (org.slf4j.Logger)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)6 Map (java.util.Map)5 ConnectionException (org.mule.runtime.api.connection.ConnectionException)5 MuleContext (org.mule.runtime.core.api.MuleContext)5 LifecycleUtils.stopIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded)5 Thread.currentThread (java.lang.Thread.currentThread)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Startable (org.mule.runtime.api.lifecycle.Startable)4