@Override
    public BackgroundException map(final AmazonClientException e) {
        final StringBuilder buffer = new StringBuilder();
        if(e instanceof AmazonServiceException) {
            final AmazonServiceException failure = (AmazonServiceException) e;
            this.append(buffer, failure.getErrorMessage());
            if(null != failure.getErrorCode()) {
                switch(failure.getStatusCode()) {
                    case HttpStatus.SC_BAD_REQUEST:
                        switch(failure.getErrorCode()) {
                            case "Throttling":
                                return new RetriableAccessDeniedException(buffer.toString(), e);
                            case "AccessDeniedException":
                                return new AccessDeniedException(buffer.toString(), e);
                            case "UnrecognizedClientException":
                                return new LoginFailureException(buffer.toString(), e);
                        }
                    case HttpStatus.SC_FORBIDDEN:
                        switch(failure.getErrorCode()) {
                            case "SignatureDoesNotMatch":
                            case "InvalidAccessKeyId":
                            case "InvalidClientTokenId":
                            case "InvalidSecurity":
                            case "MissingClientTokenId":
                            case "MissingAuthenticationToken":
                                return new LoginFailureException(buffer.toString(), e);
                        }
                }
            }
            return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(failure.getStatusCode(), buffer.toString()));
        }
        this.append(buffer, e.getMessage());
        return this.wrap(e, buffer);
    }
@Test
    public void testLoginFailure() {
        final AmazonServiceException f = new AmazonServiceException("message", null);
        f.setStatusCode(401);
        assertTrue(new AmazonServiceExceptionMappingService().map(f) instanceof LoginFailureException);
    }