in src/main/java/feign/error/AnnotationErrorDecoder.java [75:113]
Map<String, MethodErrorHandler> generateErrorHandlerMapFromApi(Class<?> apiType) {
ExceptionGenerator classLevelDefault = new ExceptionGenerator.Builder()
.withResponseBodyDecoder(responseBodyDecoder)
.withExceptionType(ErrorHandling.NO_DEFAULT.class)
.build();
Map<Integer, ExceptionGenerator> classLevelStatusCodeDefinitions =
new HashMap<Integer, ExceptionGenerator>();
Optional<ErrorHandling> classLevelErrorHandling =
readErrorHandlingIncludingInherited(apiType);
if (classLevelErrorHandling.isPresent()) {
ErrorHandlingDefinition classErrorHandlingDefinition =
readAnnotation(classLevelErrorHandling.get(), responseBodyDecoder);
classLevelDefault = classErrorHandlingDefinition.defaultThrow;
classLevelStatusCodeDefinitions = classErrorHandlingDefinition.statusCodesMap;
}
Map<String, MethodErrorHandler> methodErrorHandlerMap =
new HashMap<String, MethodErrorHandler>();
for (Method method : apiType.getMethods()) {
if (method.isAnnotationPresent(ErrorHandling.class)) {
ErrorHandlingDefinition methodErrorHandling =
readAnnotation(method.getAnnotation(ErrorHandling.class), responseBodyDecoder);
ExceptionGenerator methodDefault = methodErrorHandling.defaultThrow;
if (methodDefault.getExceptionType().equals(ErrorHandling.NO_DEFAULT.class)) {
methodDefault = classLevelDefault;
}
MethodErrorHandler methodErrorHandler =
new MethodErrorHandler(methodErrorHandling.statusCodesMap,
classLevelStatusCodeDefinitions, methodDefault);
methodErrorHandlerMap.put(configKey(apiType, method), methodErrorHandler);
}
}
return methodErrorHandlerMap;
}