use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class TypeBasedTransformerResolver method initialise.
@Override
public void initialise() throws InitialisationException {
try {
objectToString = new ObjectToString();
objectToByteArray = new ObjectToByteArray();
// these are just fallbacks that are not to go
// into the mule registry
initialiseIfNeeded(objectToString, muleContext);
initialiseIfNeeded(objectToByteArray, muleContext);
} catch (MuleException e) {
throw new InitialisationException(e, this);
}
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class ArtifactObjectSerializer method initialise.
@Override
public void initialise() throws InitialisationException {
try {
muleContext.getInjector().inject(javaInternalSerializerProtocol);
muleContext.getInjector().inject(javaExternalSerializerProtocol);
} catch (MuleException e) {
throw new InitialisationException(e, this);
}
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class MuleExtensionModelLoaderManager method start.
/**
* Will look through SPI every class that implements the {@code providerClass} and if there are repeated IDs, it will
* collect them all to throw an exception with the detailed message.
* <p/>
* The exception, if thrown, will have the following message:
* <pre>
* There are several loaders that return the same ID when looking up providers for 'org.mule.runtime.module.artifact.ExtensionModelLoader'. Full error list:
* ID [some-id] is being returned by the following classes [org.foo.FooLoader, org.bar.BarLoader]
* ID [another-id] is being returned by the following classes [org.foo2.FooLoader2, org.bar2.BarLoader2]
* </pre>
*
* @throws IllegalStateException if there are loaders with repeated IDs.
*/
@Override
public void start() throws MuleException {
final Class<ExtensionModelLoader> providerClass = ExtensionModelLoader.class;
final SpiServiceRegistry spiServiceRegistry = new SpiServiceRegistry();
final ClassLoader classLoader = containerClassLoader.getClassLoader();
final Collection<ExtensionModelLoader> extensionModelLoaders = spiServiceRegistry.lookupProviders(providerClass, classLoader);
final StringBuilder sb = new StringBuilder();
extensionModelLoaders.stream().collect(groupingBy(ExtensionModelLoader::getId)).entrySet().stream().filter(entry -> entry.getValue().size() > 1).forEach(entry -> {
// At this point we are sure there are at least 2 classes that return the same ID, we will append it to the builder
final String classes = entry.getValue().stream().map(extensionModelLoader -> extensionModelLoader.getClass().getName()).collect(Collectors.joining(", "));
sb.append(lineSeparator()).append("ID [").append(entry.getKey()).append("] is being returned by the following classes [").append(classes).append("]");
});
if (isNotBlank(sb.toString())) {
throw new MuleRuntimeException(createStaticMessage(format("There are several loaders that return the same identifier when looking up providers for '%s'. Full error list: %s", providerClass.getName(), sb.toString())));
}
extensionModelLoaders.stream().forEach(extensionModelLoader -> this.extensionModelLoaders.put(extensionModelLoader.getId(), extensionModelLoader));
if (logger.isDebugEnabled()) {
logger.debug("ExtensionModelLoader registered identifiers: {}", printExtensionModelLoaderIDs());
}
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class ErrorTypesResolutionTestCase method exceptionInfo.
@Test
public void exceptionInfo() throws Exception {
Exception epe = flowRunner("withUnderlyingConnectorError").runExpectingException();
Map<String, Object> info = ((MuleException) epe).getInfo();
assertThat(info.get("Element").toString(), containsString("withUnderlyingConnectorError/processors/0"));
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class HeisenbergMessageSourceTestCase method sourceFailsOnSuccessAndOnErrorParametersCallsOnTerminate.
@Test
public void sourceFailsOnSuccessAndOnErrorParametersCallsOnTerminate() throws Exception {
startFlow("sourceWithInvalidSuccessAndErrorParameters");
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("sourceWithInvalidSuccessAndErrorParameters/source"));
assertThat((String) me.getInfo().get(INFO_SOURCE_XML_KEY), containsString("heisenberg:success-info"));
}
Aggregations