SyncopeClientCompositeErrorException compositeException = new SyncopeClientCompositeErrorException(response
.getStatusCode());
Set<String> handledExceptions = new HashSet<String>();
for (String exceptionTypeAsString : exceptionTypesInHeaders) {
SyncopeClientExceptionType exceptionType = null;
try {
exceptionType = SyncopeClientExceptionType.getFromHeaderValue(exceptionTypeAsString);
} catch (IllegalArgumentException e) {
LOG.error("Unexpected value of " + EXCEPTION_TYPE_HEADER + ": " + exceptionTypeAsString, e);
}
if (exceptionType != null) {
handledExceptions.add(exceptionTypeAsString);
SyncopeClientException clientException = new SyncopeClientException();
clientException.setType(exceptionType);
if (response.getHeaders().get(exceptionType.getElementHeaderName()) != null
&& !response.getHeaders().get(exceptionType.getElementHeaderName()).isEmpty()) {
clientException.setElements(response.getHeaders().get(exceptionType.getElementHeaderName()));
}
compositeException.addException(clientException);
}
}