use of org.mule.runtime.api.exception.ErrorTypeRepository 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);
}
use of org.mule.runtime.api.exception.ErrorTypeRepository in project mule by mulesoft.
the class AbstractErrorTypeMatcherTestCase method setUp.
@Before
public void setUp() {
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
anyErrorType = errorTypeRepository.getAnyErrorType();
ComponentIdentifier transformationIdentifier = ComponentIdentifier.builder().name(TRANSFORMATION_ERROR_IDENTIFIER).namespace(CORE_NAMESPACE_NAME).build();
transformationErrorType = errorTypeRepository.lookupErrorType(transformationIdentifier).get();
ComponentIdentifier expressionIdentifier = ComponentIdentifier.builder().name(EXPRESSION_ERROR_IDENTIFIER).namespace(CORE_NAMESPACE_NAME).build();
expressionErrorType = errorTypeRepository.lookupErrorType(expressionIdentifier).get();
}
use of org.mule.runtime.api.exception.ErrorTypeRepository in project mule by mulesoft.
the class SingleErrorTypeMatcherTestCase method matchChild.
@Test
public void matchChild() {
ComponentIdentifier customTransformerIdentifier = ComponentIdentifier.builder().name("custom").namespace(CORE_NAMESPACE_NAME).build();
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
ErrorType customTransformerErrorType = errorTypeRepository.addErrorType(customTransformerIdentifier, transformationErrorType);
ErrorTypeMatcher transformationMatcher = new SingleErrorTypeMatcher(transformationErrorType);
assertThat(transformationMatcher.match(customTransformerErrorType), is(true));
}
use of org.mule.runtime.api.exception.ErrorTypeRepository in project mule by mulesoft.
the class ModuleFlowProcessingPhase method initialise.
@Override
public void initialise() throws InitialisationException {
final ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
componentLocator = muleContext.getConfigurationComponentLocator();
sourceResponseGenerateErrorType = errorTypeRepository.getErrorType(SOURCE_RESPONSE_GENERATE).get();
sourceResponseSendErrorType = errorTypeRepository.getErrorType(SOURCE_RESPONSE_SEND).get();
sourceErrorResponseGenerateErrorType = errorTypeRepository.getErrorType(SOURCE_ERROR_RESPONSE_GENERATE).get();
sourceErrorResponseSendErrorType = errorTypeRepository.getErrorType(SOURCE_ERROR_RESPONSE_SEND).get();
}
use of org.mule.runtime.api.exception.ErrorTypeRepository in project mule by mulesoft.
the class ExtensionErrorsRegistrantTestCase method operationTriesToAddInternalErrorType.
@Test
public void operationTriesToAddInternalErrorType() {
ErrorTypeRepository repository = mock(ErrorTypeRepository.class);
when(repository.getErrorType(any())).then((e) -> typeRepository.getErrorType(((ComponentIdentifier) e.getArguments()[0])));
ErrorModel internalRepeatedError = ErrorModelBuilder.newError(SOURCE_RESPONSE_GENERATE).build();
when(operationWithError.getErrorModels()).thenReturn(singleton(internalRepeatedError));
when(extensionModel.getOperationModels()).thenReturn(singletonList(operationWithError));
when(extensionModel.getErrorModels()).thenReturn(singleton(internalRepeatedError));
ErrorTypeLocator mockTypeLocator = mock(ErrorTypeLocator.class);
errorsRegistrant = new ExtensionErrorsRegistrant(typeRepository, mockTypeLocator);
errorsRegistrant.registerErrors(extensionModel);
verify(repository, times(0)).addErrorType(any(), any());
}
Aggregations