use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class PagingProviderProducerTestCase method closeNoisely.
@Test(expected = Exception.class)
public void closeNoisely() throws Exception {
doThrow(new DefaultMuleException(new Exception())).when(delegate).close(any());
producer.close();
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class LifecycleFilterServiceProxyTestCase method checkedExceptionThrownUnwrapped.
@Test
public void checkedExceptionThrownUnwrapped() throws Exception {
CheckedExceptionService checkExceptionService = mock(CheckedExceptionService.class);
DefaultMuleException checkedException = new DefaultMuleException("ERROR");
doThrow(checkedException).when(checkExceptionService).execute();
final CheckedExceptionService checkedExceptionServiceProxy = (CheckedExceptionService) createLifecycleFilterServiceProxy(checkExceptionService);
expected.expect(is(checkedException));
checkedExceptionServiceProxy.execute();
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class ThrowProcessor method process.
@Override
public CoreEvent process(CoreEvent event) throws MuleException {
if (count == -1 || count-- > 0) {
try {
Throwable instantiatedException = exception.newInstance();
if (error != null) {
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
ErrorType errorType = errorTypeRepository.lookupErrorType(buildFromStringRepresentation(error)).orElseThrow(() -> new DefaultMuleException(format("Could not find error: '%s'", error)));
throw new TypedException(instantiatedException, errorType);
} else {
checkArgument(instantiatedException instanceof TypedException, EXCEPTION_ERROR);
throw (TypedException) instantiatedException;
}
} catch (InstantiationException | IllegalAccessException e) {
throw new DefaultMuleException(format("Failed to instantiate exception class '%s'", exception.getSimpleName()));
}
} else {
return event;
}
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class MessagingExceptionTestCase method getCauseExceptionWithMuleCause.
@Test
public void getCauseExceptionWithMuleCause() {
DefaultMuleException causeException = new DefaultMuleException("");
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.getRootCause(), is(causeException));
}
use of org.mule.runtime.api.exception.DefaultMuleException in project mule by mulesoft.
the class MessagingExceptionTestCase method causedExactlyByWithMuleCauseWithMuleCause.
@Test
public void causedExactlyByWithMuleCauseWithMuleCause() {
DefaultMuleException causeCauseException = new DefaultMuleException("");
DefaultMuleException causeException = new DefaultMuleException(causeCauseException);
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.causedExactlyBy(DefaultMuleException.class), is(true));
assertThat(exception.causedExactlyBy(MessagingException.class), is(true));
}
Aggregations