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"));
}
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);
}
}
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;
}
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);
});
}
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);
}
}
Aggregations