use of org.mule.runtime.extension.api.annotation.error.ErrorTypeProvider in project mule by mulesoft.
the class ErrorsDeclarationEnricher method registerOperationErrorTypes.
private void registerOperationErrorTypes(MethodElement operationMethod, ComponentDeclaration operation, ErrorsModelFactory errorModelDescriber, ErrorTypeDefinition<?>[] extensionErrorTypes, Type extensionElement) {
if (extensionElement.getDeclaringClass().isPresent()) {
getOperationThrowsDeclaration(operationMethod, extensionElement).ifPresent(throwsAnnotation -> {
Class<? extends ErrorTypeProvider>[] providers = throwsAnnotation.value();
Stream.of(providers).forEach(provider -> {
try {
ErrorTypeProvider errorTypeProvider = provider.newInstance();
errorTypeProvider.getErrorTypes().stream().map(error -> validateOperationThrows(extensionErrorTypes, error)).map(errorModelDescriber::getErrorModel).forEach(operation::addErrorModel);
} catch (InstantiationException | IllegalAccessException e) {
throw new MuleRuntimeException(createStaticMessage("Could not create ErrorTypeProvider of type " + provider.getName()), e);
}
});
});
}
}
Aggregations