summaryrefslogtreecommitdiffstats
path: root/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
index 7e4397ec29..e91dc43af9 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
@@ -245,18 +245,22 @@ public class AAIResourcesClient extends AAIClient {
String json;
try {
json = this.createClient(uri).get(String.class)
- .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI"));
+ .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI", Optional.empty()));
} catch (NotFoundException e) {
- throw createException(c, "could not construct uri for use with A&AI");
+ throw createException(c, "could not construct uri for use with A&AI", Optional.of(e));
}
return new AAIResultWrapper(json);
}
- private RuntimeException createException(Class<? extends RuntimeException> c, String message) {
+ private RuntimeException createException(Class<? extends RuntimeException> c, String message, Optional<Throwable> t) {
RuntimeException e;
try {
- e = c.getConstructor(String.class).newInstance(message);
+ if (t.isPresent()) {
+ e = c.getConstructor(String.class, Throwable.class).newInstance(message, t.get());
+ } else {
+ e = c.getConstructor(String.class).newInstance(message);
+ }
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e1) {
throw new IllegalArgumentException("could not create instance for " + c.getName());