final SyncopeClientCompositeException compException = SyncopeClientException.buildComposite();
final Set<String> handledExceptions = new HashSet<String>();
for (Object exceptionTypeValue : exTypesInHeaders) {
final String exTypeAsString = (String) exceptionTypeValue;
ClientExceptionType exceptionType = null;
try {
exceptionType = ClientExceptionType.fromHeaderValue(exTypeAsString);
} catch (IllegalArgumentException e) {
LOG.error("Unexpected value of " + RESTHeaders.ERROR_CODE + ": " + exTypeAsString, e);
}
if (exceptionType != null) {
handledExceptions.add(exTypeAsString);
final SyncopeClientException clientException = SyncopeClientException.build(exceptionType);
if (response.getHeaders().get(RESTHeaders.ERROR_INFO) != null
&& !response.getHeaders().get(RESTHeaders.ERROR_INFO).isEmpty()) {
for (Object value : response.getHeaders().get(RESTHeaders.ERROR_INFO)) {
final String element = value.toString();
if (element.startsWith(exceptionType.getHeaderValue())) {
clientException.getElements().add(StringUtils.substringAfter(value.toString(), ":"));
}
}
}
compException.addException(clientException);