Class 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 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.