use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class MessagingExceptionTestCase method getCauseExceptionWithMuleCauseWithMuleCause.
@Test
public void getCauseExceptionWithMuleCauseWithMuleCause() {
DefaultMuleException causeCauseException = new DefaultMuleException("");
DefaultMuleException causeException = new DefaultMuleException(causeCauseException);
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.getRootCause(), is(causeCauseException));
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class MessagingExceptionTestCase method causedByWithMuleCauseWithMuleCause.
@Test
public void causedByWithMuleCauseWithMuleCause() {
DefaultMuleException causeCauseException = new DefaultMuleException("");
DefaultMuleException causeException = new DefaultMuleException(causeCauseException);
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.causedBy(DefaultMuleException.class), is(true));
assertThat(exception.causedBy(MessagingException.class), is(true));
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method childErrorsErrorBinding.
@Test
public void childErrorsErrorBinding() throws Exception {
String childErrorMessage = "error";
String otherChildErrorMessage = "oops";
ErrorType errorType = mock(ErrorType.class);
Error error = mock(Error.class);
when(error.getChildErrors()).thenReturn(asList(ErrorBuilder.builder(new IOException(childErrorMessage)).errorType(errorType).build(), ErrorBuilder.builder(new DefaultMuleException(otherChildErrorMessage)).errorType(errorType).build()));
Optional opt = Optional.of(error);
CoreEvent event = getEventWithError(opt);
doReturn(testEvent().getMessage()).when(event).getMessage();
String expression = "error.childErrors reduce ((child, acc = '') -> acc ++ child.cause.message)";
TypedValue result = expressionLanguage.evaluate(expression, event, BindingContext.builder().build());
assertThat(result.getValue(), is(format("%s%s", childErrorMessage, otherChildErrorMessage)));
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class SystemUtils method parseCommandLine.
// TODO MULE-1947 Command-line arguments should be handled exclusively by the bootloader
private static CommandLine parseCommandLine(String[] args, String[][] opts) throws MuleException {
Options options = new Options();
for (String[] opt : opts) {
options.addOption(opt[0], opt[1].equals("true") ? true : false, opt[2]);
}
BasicParser parser = new BasicParser();
try {
CommandLine line = parser.parse(options, args, true);
if (line == null) {
throw new DefaultMuleException("Unknown error parsing the Mule command line");
}
return line;
} catch (ParseException p) {
throw new DefaultMuleException("Unable to parse the Mule command line because of: " + p.toString(), p);
}
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class TryScope method process.
@Override
public CoreEvent process(final CoreEvent event) throws MuleException {
if (nestedChain == null) {
return event;
} else {
ExecutionTemplate<CoreEvent> executionTemplate = createScopeTransactionalExecutionTemplate(muleContext, transactionConfig);
ExecutionCallback<CoreEvent> processingCallback = () -> {
try {
CoreEvent e = processToApply(event, p -> from(p).flatMap(request -> processWithChildContext(request, nestedChain, ofNullable(getLocation()), messagingExceptionHandler)));
return e;
} catch (Exception e) {
throw e;
}
};
try {
return executionTemplate.execute(processingCallback);
} catch (MuleException e) {
throw e;
} catch (Exception e) {
throw new DefaultMuleException(errorInvokingMessageProcessorWithinTransaction(nestedChain, transactionConfig), e);
}
}
}
Aggregations