Search in sources :

Example 1 with DisjunctiveErrorTypeMatcher

use of org.mule.runtime.core.api.exception.DisjunctiveErrorTypeMatcher in project mule by mulesoft.

the class TemplateOnErrorHandler method createErrorType.

public static ErrorTypeMatcher createErrorType(ErrorTypeRepository errorTypeRepository, String errorTypeNames) {
    if (errorTypeNames == null) {
        return null;
    }
    String[] errorTypeIdentifiers = errorTypeNames.split(",");
    List<ErrorTypeMatcher> matchers = stream(errorTypeIdentifiers).map((identifier) -> {
        String parsedIdentifier = identifier.trim();
        return new SingleErrorTypeMatcher(errorTypeRepository.lookupErrorType(buildFromStringRepresentation(parsedIdentifier)).orElseThrow(() -> new MuleRuntimeException(createStaticMessage("Could not find ErrorType for the given identifier: '%s'", parsedIdentifier))));
    }).collect(toList());
    return new DisjunctiveErrorTypeMatcher(matchers);
}
Also used : ReplyToPropertyRequestReplyReplier(org.mule.runtime.core.privileged.routing.requestreply.ReplyToPropertyRequestReplyReplier) Optional.empty(java.util.Optional.empty) MessageProcessors.newChain(org.mule.runtime.core.privileged.processor.MessageProcessors.newChain) DisjunctiveErrorTypeMatcher(org.mule.runtime.core.api.exception.DisjunctiveErrorTypeMatcher) ComponentIdentifier.buildFromStringRepresentation(org.mule.runtime.api.component.ComponentIdentifier.buildFromStringRepresentation) Exceptions.unwrap(org.mule.runtime.core.api.rx.Exceptions.unwrap) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ErrorTypeRepository(org.mule.runtime.api.exception.ErrorTypeRepository) Processor(org.mule.runtime.core.api.processor.Processor) Function(java.util.function.Function) PROCESS_START(org.mule.runtime.api.notification.ErrorHandlerNotification.PROCESS_START) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ConfigurationComponentLocator(org.mule.runtime.api.component.location.ConfigurationComponentLocator) ErrorHandlerNotification(org.mule.runtime.api.notification.ErrorHandlerNotification) MuleContext(org.mule.runtime.core.api.MuleContext) MuleException(org.mule.runtime.api.exception.MuleException) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) Mono.from(reactor.core.publisher.Mono.from) Mono.just(reactor.core.publisher.Mono.just) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) DefaultExceptionPayload(org.mule.runtime.core.internal.message.DefaultExceptionPayload) ComponentAnnotations.updateRootContainerName(org.mule.runtime.core.internal.component.ComponentAnnotations.updateRootContainerName) Optional.ofNullable(java.util.Optional.ofNullable) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Publisher(org.reactivestreams.Publisher) NullExceptionHandler(org.mule.runtime.core.api.exception.NullExceptionHandler) EnrichedNotificationInfo.createInfo(org.mule.runtime.api.notification.EnrichedNotificationInfo.createInfo) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) NoExtend(org.mule.api.annotation.NoExtend) TransactionCoordination(org.mule.runtime.core.api.transaction.TransactionCoordination) ProcessingStrategy(org.mule.runtime.core.api.processor.strategy.ProcessingStrategy) ErrorTypeMatcher(org.mule.runtime.core.api.exception.ErrorTypeMatcher) MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) MessageProcessors.processWithChildContext(org.mule.runtime.core.privileged.processor.MessageProcessors.processWithChildContext) PROCESS_END(org.mule.runtime.api.notification.ErrorHandlerNotification.PROCESS_END) Optional(java.util.Optional) TRUE(java.lang.Boolean.TRUE) Arrays.stream(java.util.Arrays.stream) MessageProcessors.getProcessingStrategy(org.mule.runtime.core.privileged.processor.MessageProcessors.getProcessingStrategy) DisjunctiveErrorTypeMatcher(org.mule.runtime.core.api.exception.DisjunctiveErrorTypeMatcher) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) ErrorTypeMatcher(org.mule.runtime.core.api.exception.ErrorTypeMatcher) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) DisjunctiveErrorTypeMatcher(org.mule.runtime.core.api.exception.DisjunctiveErrorTypeMatcher) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher)

Aggregations

TRUE (java.lang.Boolean.TRUE)1 ArrayList (java.util.ArrayList)1 Arrays.stream (java.util.Arrays.stream)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Collectors.toList (java.util.stream.Collectors.toList)1 Inject (javax.inject.Inject)1 NoExtend (org.mule.api.annotation.NoExtend)1 ComponentIdentifier.buildFromStringRepresentation (org.mule.runtime.api.component.ComponentIdentifier.buildFromStringRepresentation)1 ConfigurationComponentLocator (org.mule.runtime.api.component.location.ConfigurationComponentLocator)1 ErrorTypeRepository (org.mule.runtime.api.exception.ErrorTypeRepository)1 MuleException (org.mule.runtime.api.exception.MuleException)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1