- return target.request().headers(getAaiHeaders()).build("PATCH", Entity.json(body))
- .property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true).invoke();
+ try {
+ Response response = target.request().headers(getAaiHeaders()).build("PATCH", Entity.json(body))
+ .property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true).invoke();
+ if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
+ throw new CorrelationException("Failed to connecto to AAI. \nCause: "
+ + response.getStatusInfo().getReasonPhrase() + "\nDetails: \n"
+ + getErrorMsg(String.format("%s%s", host, path), body, response));
+ }
+ } catch (CorrelationException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new CorrelationException(e.getMessage() + "More info: "
+ + getErrorMsg(String.format("%s%s", host, path), body, null), e);
+ }