in src/main/java/org/apache/fineract/cn/api/util/AnnotatedErrorDecoder.java [121:153]
private Optional<Exception> constructException(
final Response response,
final ThrowsException throwsExceptionAnnotations) {
try {
try {
final Constructor<? extends RuntimeException> oneResponseArgumentConstructor =
throwsExceptionAnnotations.exception().getConstructor(Response.class);
return Optional.of(oneResponseArgumentConstructor.newInstance(response));
} catch (final NoSuchMethodException e) {
try {
final Constructor<? extends RuntimeException> noArgumentConstructor =
throwsExceptionAnnotations.exception().getConstructor();
return Optional.of(noArgumentConstructor.newInstance());
}
catch (final NoSuchMethodException e2) {
final Constructor<? extends RuntimeException> noStringArgumentConstructor =
throwsExceptionAnnotations.exception().getConstructor(String.class);
return Optional.of(noStringArgumentConstructor.newInstance(stringifyBody(response)));
}
}
} catch (final InvocationTargetException
| IllegalAccessException
| InstantiationException
| NoSuchMethodException e) {
logger.error("Instantiating exception {}, in for status {} failed with an exception",
throwsExceptionAnnotations.exception(), throwsExceptionAnnotations.status(), e);
return Optional.empty();
}
}