use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class DisjunctiveErrorTypeMatcherTestCase method allMatch.
@Test
public void allMatch() {
ErrorType mockErrorType = mock(ErrorType.class);
when(mockErrorType.getParentErrorType()).thenReturn(transformationErrorType);
ErrorTypeMatcher matcherWithTwoTransformation = createMatcher(transformationErrorType, mockErrorType);
assertThat(matcherWithTwoTransformation.match(mockErrorType), is(true));
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class DefaultErrorTypeRepository method addErrorType.
/**
* {@inheritDoc}
*/
@Override
public ErrorType addErrorType(ComponentIdentifier errorTypeIdentifier, ErrorType parentErrorType) {
ErrorType errorType = buildErrorType(errorTypeIdentifier, parentErrorType);
errorTypes.put(errorTypeIdentifier, errorType);
return errorType;
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class ErrorTypeRepositoryFactory method createDefaultErrorTypeRepository.
/**
* Creates the default {@link ErrorTypeRepository} to use in mule.
* <p>
* The {@link ErrorTypeRepository} gets populated with the default mappings between common core exceptions and core error types.
*
* @return a new {@link ErrorTypeRepository}.
*/
public static ErrorTypeRepository createDefaultErrorTypeRepository() {
ErrorTypeRepository errorTypeRepository = new DefaultErrorTypeRepository();
errorTypeRepository.addErrorType(TRANSFORMATION, errorTypeRepository.getAnyErrorType());
errorTypeRepository.addErrorType(EXPRESSION, errorTypeRepository.getAnyErrorType());
final ErrorType validationErrorType = errorTypeRepository.addErrorType(VALIDATION, errorTypeRepository.getAnyErrorType());
errorTypeRepository.addErrorType(DUPLICATE_MESSAGE, validationErrorType);
errorTypeRepository.addErrorType(REDELIVERY_EXHAUSTED, errorTypeRepository.getAnyErrorType());
final ErrorType connectivityErrorType = errorTypeRepository.addErrorType(CONNECTIVITY, errorTypeRepository.getAnyErrorType());
errorTypeRepository.addErrorType(RETRY_EXHAUSTED, connectivityErrorType);
errorTypeRepository.addErrorType(ROUTING, errorTypeRepository.getAnyErrorType());
errorTypeRepository.addErrorType(SECURITY, errorTypeRepository.getAnyErrorType());
errorTypeRepository.addErrorType(CLIENT_SECURITY, errorTypeRepository.getErrorType(SECURITY).get());
errorTypeRepository.addErrorType(SERVER_SECURITY, errorTypeRepository.getErrorType(SECURITY).get());
errorTypeRepository.addErrorType(NOT_PERMITTED, errorTypeRepository.getErrorType(SERVER_SECURITY).get());
errorTypeRepository.addErrorType(STREAM_MAXIMUM_SIZE_EXCEEDED, errorTypeRepository.getAnyErrorType());
errorTypeRepository.addInternalErrorType(OVERLOAD, errorTypeRepository.getCriticalErrorType());
errorTypeRepository.addInternalErrorType(FLOW_BACK_PRESSURE, errorTypeRepository.getErrorType(OVERLOAD).get());
errorTypeRepository.addInternalErrorType(FATAL, errorTypeRepository.getCriticalErrorType());
errorTypeRepository.addErrorType(TIMEOUT, errorTypeRepository.getAnyErrorType());
errorTypeRepository.addErrorType(COMPOSITE_ROUTING, errorTypeRepository.getErrorType(ROUTING).get());
final ErrorType sourceErrorType = errorTypeRepository.getSourceErrorType();
errorTypeRepository.addErrorType(SOURCE_RESPONSE_GENERATE, errorTypeRepository.getSourceResponseErrorType());
errorTypeRepository.addErrorType(SOURCE_RESPONSE_SEND, errorTypeRepository.getSourceResponseErrorType());
errorTypeRepository.addInternalErrorType(SOURCE_ERROR_RESPONSE_GENERATE, sourceErrorType);
errorTypeRepository.addInternalErrorType(SOURCE_ERROR_RESPONSE_SEND, sourceErrorType);
return errorTypeRepository;
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class OnErrorContinueHandler method doInitialise.
@Override
protected void doInitialise(MuleContext muleContext) throws InitialisationException {
super.doInitialise(muleContext);
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
sourceErrorMatcher = new SingleErrorTypeMatcher(errorTypeRepository.getSourceResponseErrorType());
if (errorType != null) {
String[] errors = errorType.split(",");
for (String error : errors) {
// Since the partial initialisation was successful, we know this error ids are safe
String sanitizedError = error.trim();
ErrorType errorType = errorTypeRepository.lookupErrorType(buildFromStringRepresentation(sanitizedError)).get();
if (sourceErrorMatcher.match(errorType)) {
throw new InitialisationException(getInitialisationError(sanitizedError), this);
}
}
} else if (when == null) {
// No error type and no expression, force ANY matcher
errorTypeMatcher = new SingleErrorTypeMatcher(errorTypeRepository.getAnyErrorType());
}
}
use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.
the class MessagingExceptionResolver method collectErrors.
private List<Pair<Throwable, ErrorType>> collectErrors(Component obj, MessagingException me, ErrorTypeLocator locator) {
List<Pair<Throwable, ErrorType>> errors = new LinkedList<>();
getExceptionsAsList(me).forEach(e -> {
ErrorType type = errorTypeFromException(obj, locator, e);
if (!isUnknownMuleError(type) && !isCriticalMuleError(type)) {
errors.add(new Pair<>(e, type));
}
});
return errors;
}
Aggregations