Search in sources :

Example 16 with MuleException

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

the class HeisenbergMessageSourceTestCase method failureInFlowCallsOnErrorDirectlyAndFailsHandlingIt.

@Test
public void failureInFlowCallsOnErrorDirectlyAndFailsHandlingIt() throws Exception {
    startFlow("failureInFlowCallsOnErrorDirectlyAndFailsHandlingIt");
    probe(TIMEOUT_MILLIS, POLL_DELAY_MILLIS, () -> assertState(false, false, true));
    assertThat(HeisenbergSource.terminateStatus, is(ERROR_INVOKE));
    Optional<Error> optionalError = HeisenbergSource.error;
    assertThat(optionalError, is(not(empty())));
    assertThat(optionalError.get().getErrorType(), is(errorType(SOURCE_ERROR_RESPONSE_GENERATE)));
    MuleException me = (MuleException) unwrap(optionalError.get().getCause());
    assertThat((String) me.getInfo().get(INFO_LOCATION_KEY), containsString("failureInFlowCallsOnErrorDirectlyAndFailsHandlingIt/source"));
    assertThat((String) me.getInfo().get(INFO_SOURCE_XML_KEY), containsString("heisenberg:success-info"));
}
Also used : Error(org.mule.runtime.api.message.Error) MuleException(org.mule.runtime.api.exception.MuleException) Test(org.junit.Test)

Example 17 with MuleException

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

the class DefaultExtensionsClient method disposeProcessor.

private void disposeProcessor(OperationMessageProcessor processor) {
    try {
        processor.stop();
        processor.dispose();
    } catch (MuleException e) {
        throw new MuleRuntimeException(createStaticMessage("Error while disposing the executing operation"), e);
    }
}
Also used : MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) MuleException(org.mule.runtime.api.exception.MuleException)

Example 18 with MuleException

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

the class DefaultExtensionsClient method resolveParameters.

private Map<String, ValueResolver> resolveParameters(Map<String, Object> parameters, CoreEvent event) {
    LinkedHashMap<String, ValueResolver> values = new LinkedHashMap<>();
    parameters.forEach((name, value) -> {
        if (value instanceof ComplexParameter) {
            ComplexParameter complex = (ComplexParameter) value;
            DefaultObjectBuilder<?> builder = new DefaultObjectBuilder<>(complex.getType());
            resolveParameters(complex.getParameters(), event).forEach((propertyName, valueResolver) -> {
                try {
                    initialiseIfNeeded(valueResolver, true, muleContext);
                    builder.addPropertyResolver(propertyName, valueResolver);
                } catch (InitialisationException e) {
                    throw new MuleRuntimeException(e);
                }
            });
            try {
                values.put(name, new StaticValueResolver<>(builder.build(from(event))));
            } catch (MuleException e) {
                throw new MuleRuntimeException(createStaticMessage(format("Could not construct parameter [%s]", name)), e);
            }
        } else {
            if (value instanceof String && parser.isContainsTemplate((String) value)) {
                values.put(name, new ExpressionValueResolver((String) value));
            } else {
                values.put(name, new StaticValueResolver<>(value));
            }
        }
    });
    return values;
}
Also used : ComplexParameter(org.mule.runtime.extension.internal.client.ComplexParameter) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionValueResolver) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder) MuleException(org.mule.runtime.api.exception.MuleException) LinkedHashMap(java.util.LinkedHashMap) ExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionValueResolver)

Example 19 with MuleException

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

the class DefaultConfigurationProviderFactory method createStaticConfigurationProvider.

/**
 * {@inheritDoc}
 */
@Override
public ConfigurationProvider createStaticConfigurationProvider(String name, ExtensionModel extensionModel, ConfigurationModel configurationModel, ResolverSet resolverSet, ConnectionProviderValueResolver connectionProviderResolver, ReflectionCache reflectionCache, MuleContext muleContext) throws Exception {
    return withExtensionClassLoader(extensionModel, () -> {
        configureConnectionProviderResolver(name, connectionProviderResolver);
        ConfigurationInstance configuration;
        CoreEvent initialiserEvent = null;
        try {
            initialiserEvent = getInitialiserEvent(muleContext);
            initialiseIfNeeded(resolverSet, true, muleContext);
            configuration = new ConfigurationInstanceFactory(extensionModel, configurationModel, resolverSet, reflectionCache, muleContext).createConfiguration(name, initialiserEvent, connectionProviderResolver);
        } catch (MuleException e) {
            throw new ConfigurationException(createStaticMessage(format("Could not create configuration '%s' for the '%s'", name, extensionModel.getName())), e);
        } finally {
            if (initialiserEvent != null) {
                ((BaseEventContext) initialiserEvent.getContext()).success();
            }
        }
        return new ConfigurationProviderToolingAdapter(name, extensionModel, configurationModel, configuration, reflectionCache, muleContext);
    });
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) MuleException(org.mule.runtime.api.exception.MuleException) ConfigurationInstance(org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)

Example 20 with MuleException

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

the class DefaultImplicitConnectionProviderFactory method createImplicitConnectionProvider.

/**
 * {@inheritDoc}
 */
@Override
public <T> Pair<ConnectionProvider<T>, ResolverSetResult> createImplicitConnectionProvider(String configName, CoreEvent event) {
    ResolverSet resolverSet = resolverSetProvider.get();
    ConnectionProviderObjectBuilder<T> builder = new DefaultConnectionProviderObjectBuilder<>(connectionProviderModel, resolverSet, extensionModel, muleContext);
    builder.setOwnerConfigName(configName);
    try {
        return builder.build(from(event));
    } catch (MuleException e) {
        throw new MuleRuntimeException(e);
    }
}
Also used : ResolverSet(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet) ImplicitObjectUtils.buildImplicitResolverSet(org.mule.runtime.module.extension.internal.loader.utils.ImplicitObjectUtils.buildImplicitResolverSet) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) 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