### Question:
AmazonHttpClient { void afterError(Request<?> request, Response<?> response, List<RequestHandler2> requestHandler2s, AmazonClientException e) { for (final RequestHandler2 handler2 : requestHandler2s) { handler2.afterError(request, response, e); } } AmazonHttpClient(ClientConfiguration config); @Deprecated  AmazonHttpClient(ClientConfiguration config,
            RequestMetricCollector requestMetricCollector);  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient); @Deprecated  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient,
            RequestMetricCollector requestMetricCollector); @Deprecated ResponseMetadata getResponseMetadataForRequest(AmazonWebServiceRequest request); Response<T> execute(Request<?> request,
            HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler,
            HttpResponseHandler<AmazonServiceException> errorResponseHandler,
            ExecutionContext executionContext); void shutdown(); RequestMetricCollector getRequestMetricCollector();  }### Answer:
@Test public void testAfterError() { final Request<?> testRequest = new DefaultRequest<String>("test"); final Response<?> testResponse = new Response<String>("test", new HttpResponse.Builder().build()); final List<Object> calls = new ArrayList<Object>(); List<RequestHandler2> handlers = new ArrayList<RequestHandler2>(); final AmazonClientException ace = new AmazonClientException("Test exception"); RequestHandler2 handler = new RequestHandler2() { @Override public void beforeRequest(Request<?> request) { } @Override public void afterResponse(Request<?> request, Response<?> response) { } @Override public void afterError(Request<?> request, Response<?> response, Exception e) { assertSame(testRequest, request); assertSame(testResponse, response); assertSame(e, ace); calls.add(this); } }; handlers.add(handler); client.afterError(testRequest, testResponse, handlers, ace); assertEquals(calls.size(), 1); assertTrue(calls.contains(handler)); }