public BackgroundException map(HttpResponse response) throws IOException {
        final S3ServiceException failure;
        if(null == response.getEntity()) {
            failure = new S3ServiceException(response.getStatusLine().getReasonPhrase());
        }
        else {
            EntityUtils.updateEntity(response, new BufferedHttpEntity(response.getEntity()));
            failure = new S3ServiceException(response.getStatusLine().getReasonPhrase(),
                    EntityUtils.toString(response.getEntity()));
        }
        failure.setResponseCode(response.getStatusLine().getStatusCode());
        if(response.containsHeader(MINIO_ERROR_CODE)) {
            failure.setErrorCode(response.getFirstHeader(MINIO_ERROR_CODE).getValue());
        }
        if(response.containsHeader(MINIO_ERROR_DESCRIPTION)) {
            failure.setErrorMessage(response.getFirstHeader(MINIO_ERROR_DESCRIPTION).getValue());
        }
        return this.map(failure);
    }
@Test
    public void testEmpty() {
        assertEquals("Listing directory / failed.",
            new S3ExceptionMappingService().map("Listing directory {0} failed", new ServiceException(), new Path("/", EnumSet.of(Path.Type.directory))).getMessage());
    }