Search in sources :

Example 11 with DefaultMuleException

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();
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) MuleException(org.mule.runtime.api.exception.MuleException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 12 with DefaultMuleException

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();
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) Test(org.junit.Test)

Example 13 with DefaultMuleException

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;
    }
}
Also used : ErrorTypeRepository(org.mule.runtime.api.exception.ErrorTypeRepository) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) ErrorType(org.mule.runtime.api.message.ErrorType) TypedException(org.mule.runtime.api.exception.TypedException)

Example 14 with DefaultMuleException

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));
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 15 with DefaultMuleException

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));
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)26 Test (org.junit.Test)12 MuleException (org.mule.runtime.api.exception.MuleException)12 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)8 SmallTest (org.mule.tck.size.SmallTest)6 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)5 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)5 IOException (java.io.IOException)3 ConnectionException (org.mule.runtime.api.connection.ConnectionException)3 URL (java.net.URL)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ConnectionProvider (org.mule.runtime.api.connection.ConnectionProvider)2 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2 ObjectStoreException (org.mule.runtime.api.store.ObjectStoreException)2 MuleCoreExtension (org.mule.runtime.container.api.MuleCoreExtension)2 Processor (org.mule.runtime.core.api.processor.Processor)2 MessageProcessors.processToApply (org.mule.runtime.core.privileged.processor.MessageProcessors.processToApply)2 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)2 RoutingException (org.mule.runtime.core.privileged.routing.RoutingException)2