@Override
    public BackgroundException map(final ApiException failure) {
        final StringBuilder buffer = new StringBuilder();
        if(StringUtils.isNotBlank(failure.getMessage())) {
            for(String s : StringUtils.split(failure.getMessage(), ",")) {
                this.append(buffer, LocaleFactory.localizedString(s, "EUE"));
            }
        }
        if(null != failure.getResponseHeaders()) {
            final List<List<String>> headers = failure.getResponseHeaders().entrySet().stream()
                    .filter(e -> "X-UI-ENHANCED-STATUS".equalsIgnoreCase(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
            for(List<String> header : headers) {
                for(String s : header) {
                    this.append(buffer, LocaleFactory.localizedString(s, "EUE"));
                }
            }
        }
        for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
            if(cause instanceof ProcessingException) {
                return new InteroperabilityException(cause.getMessage(), cause);
            }
            if(cause instanceof SocketException) {
                // Map Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Broken pipe
                return new DefaultSocketExceptionMappingService().map((SocketException) cause);
            }
            if(cause instanceof HttpResponseException) {
                return new DefaultHttpResponseExceptionMappingService().map((HttpResponseException) cause);
            }
            if(cause instanceof IOException) {
                return new DefaultIOExceptionMappingService().map((IOException) cause);
            }
            if(cause instanceof IllegalStateException) {
                // Caused by: ApiException: javax.ws.rs.ProcessingException: java.lang.IllegalStateException: Connection pool shut down
                return new ConnectionCanceledException(cause);
            }
        }
        switch(failure.getCode()) {
            case HttpStatus.SC_UNPROCESSABLE_ENTITY:
                return new LockedException(buffer.toString(), failure);
            case HttpStatus.SC_TOO_MANY_REQUESTS:
                final Optional<Map.Entry<String, List<String>>> header
                        = failure.getResponseHeaders().entrySet().stream().filter(e -> HttpHeaders.RETRY_AFTER.equals(e.getKey())).findAny();
                if(header.isPresent()) {
                    final Optional<String> value = header.get().getValue().stream().findAny();
                    return value.map(s -> new RetriableAccessDeniedException(buffer.toString(),
                            Duration.ofSeconds(Long.parseLong(s)), failure)).orElseGet(() -> new RetriableAccessDeniedException(buffer.toString(), failure));
                }
        }
        return new DefaultHttpResponseExceptionMappingService().map(failure, buffer, failure.getCode());
    }
@Test
    public void testParseError() {
        assertEquals("LIMIT_MAX_FOLDER_COUNT. LIMIT_MAX_RESOURCE_COUNT. Please contact your web hosting service provider for assistance.",
                new EueExceptionMappingService().map(new ApiException("LIMIT_MAX_FOLDER_COUNT,LIMIT_MAX_RESOURCE_COUNT", null, 500, null)).getDetail());
    }