Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2010, Inc. or its affiliates. All Rights Reserved.
  * Licensed under the Apache License, Version 2.0 (the "License").
  * You may not use this file except in compliance with the License.
  * A copy of the License is located at
 * or in the "license" file accompanying this file. This file is distributed
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
package com.amazonaws.http;
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).
        implements HttpResponseHandler<AmazonServiceException> {

The list of error response unmarshallers to try to apply to error responses.
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.

unmarshallerList The list of unmarshallers to try using when handling an error response.
            List<Unmarshaller<AmazonServiceExceptionNode>> unmarshallerList) {
        this. = unmarshallerList;
    /* (non-Javadoc)
     * @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse)
    public AmazonServiceException handle(HttpResponse errorResponse)
            throws Exception {
        Document document = XpathUtils.documentFrom(errorResponse.getContent());
         * We need to select which exception unmarshaller is the correct one to
         * use from all the possible exceptions this operation can throw.
         * Currently we rely on the unmarshallers to return null if they can't
         * unmarshall the response, but we might need something a little more
         * sophisticated in the future.
        for (Unmarshaller<AmazonServiceExceptionNodeunmarshaller : ) {
            AmazonServiceException ase = unmarshaller.unmarshall(document);
            if (ase != null) {
                return ase;
        throw new AmazonClientException("Unable to unmarshall error response from service");

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.

    public boolean needsConnectionLeftOpen() {
        return false;
New to GrepCode? Check out our FAQ X