com.amazonaws.http
Class DefaultErrorResponseHandler

java.lang.Object
  extended by com.amazonaws.http.DefaultErrorResponseHandler
All Implemented Interfaces:
HttpResponseHandler<AmazonServiceException>

public class DefaultErrorResponseHandler
extends Object
implements HttpResponseHandler<AmazonServiceException>

Implementation of HttpResponseHandler that handles only error responses from Amazon Web Services. A list of unmarshallers is passed into the constructor, and while handling a response, each unmarshaller is tried, in order, until one is found that can successfully unmarshall the error response. If no unmarshaller is found that can unmarshall the error response, a generic AmazonServiceException is created and populated with the AWS error response information (error message, AWS error code, AWS request ID, etc).


Constructor Summary
DefaultErrorResponseHandler(List<com.amazonaws.transform.Unmarshaller<AmazonServiceException,Node>> unmarshallerList)
          Constructs a new DefaultErrorResponseHandler that will handle error responses from Amazon services using the specified list of unmarshallers.
 
Method Summary
 AmazonServiceException handle(HttpResponse errorResponse)
          Accepts an HTTP response object, and returns an object of type T.
 boolean needsConnectionLeftOpen()
          Since this response handler completely consumes all the data from the underlying HTTP connection during the handle method, we don't need to keep the HTTP connection open.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultErrorResponseHandler

public DefaultErrorResponseHandler(List<com.amazonaws.transform.Unmarshaller<AmazonServiceException,Node>> unmarshallerList)
Constructs a new DefaultErrorResponseHandler that will handle error responses from Amazon services using the specified list of unmarshallers. Each unmarshaller will be tried, in order, until one is found that can unmarshall the error response.

Parameters:
unmarshallerList - The list of unmarshallers to try using when handling an error response.
Method Detail

handle

public AmazonServiceException handle(HttpResponse errorResponse)
                              throws Exception
Description copied from interface: HttpResponseHandler
Accepts an HTTP response object, and returns an object of type T. Individual implementations may choose to handle the response however they need to, and return any type that they need to.

Specified by:
handle in interface HttpResponseHandler<AmazonServiceException>
Parameters:
errorResponse - The HTTP response to handle, as received from an AWS service.
Returns:
An object of type T, as defined by individual implementations.
Throws:
Exception - If any problems are encountered handling the response.

needsConnectionLeftOpen

public boolean needsConnectionLeftOpen()
Since this response handler completely consumes all the data from the underlying HTTP connection during the handle method, we don't need to keep the HTTP connection open.

Specified by:
needsConnectionLeftOpen in interface HttpResponseHandler<AmazonServiceException>
Returns:
True if this response handler requires that the underlying HTTP connection be left open, and not automatically closed, otherwise false.
See Also:
HttpResponseHandler.needsConnectionLeftOpen()


Copyright © 2016. All rights reserved.