Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 Amazon.com, 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
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.s3.internal;
 
 import java.util.Map;
 
Builder class that builds the AmazonS3Exception
 
 public class AmazonS3ExceptionBuilder {

    
The unique AWS identifier for the service request the caller made. The AWS request ID can uniquely identify the AWS request, and is used for reporting an error to AWS support team.
 
     private String requestId;

    
The AWS error code represented by this exception (ex: InvalidParameterValue).
 
     private String errorCode;

    
The error message as returned by the service.
 
     private String errorMessage;

    
The HTTP status code that was returned with this error
 
     private int statusCode;

    
An S3 specific request ID that provides additional debugging information.
 
     private String extendedRequestId;

    
Additional information on the exception.
 
     private Map<StringStringadditionalDetails;

    
Returns the error XML received in the HTTP Response or null if the exception is constructed from the headers.
 
     private String errorResponseXml;

    
Returns the AWS request ID that uniquely identifies the service request the caller made.

Returns:
The AWS request ID that uniquely identifies the service request the caller made.
 
     public String getRequestId() {
         return ;
     }

    
Sets the AWS requestId for this exception.

Parameters:
requestId The unique identifier for the service request the caller made.
 
     public void setRequestId(String requestId) {
         this. = requestId;
     }

    
Sets the AWS error code represented by this exception.

Parameters:
errorCode The AWS error code represented by this exception.
 
     public void setErrorCode(String errorCode) {
         this. = errorCode;
     }

    
Returns the AWS error code represented by this exception.

Returns:
The AWS error code represented by this exception.
    public String getErrorCode() {
        return ;
    }

    
Returns the human-readable error message provided by the service
    public String getErrorMessage() {
        return ;
    }

    
Sets the human-readable error message provided by the service
    public void setErrorMessage(String errorMessage) {
        this. = errorMessage;
    }

    
Sets the HTTP status code that was returned with this service exception.

Parameters:
statusCode The HTTP status code that was returned with this service exception.
    public void setStatusCode(int statusCode) {
        this. = statusCode;
    }

    
Returns the HTTP status code that was returned with this service exception.

Returns:
The HTTP status code that was returned with this service exception.
    public int getStatusCode() {
        return ;
    }

    
Gets Amazon S3's extended request ID. This ID is required debugging information in the case the user needs to contact Amazon about an issue where Amazon S3 is incorrectly handling a request.

    public String getExtendedRequestId() {
        return ;
    }

    
    public void setExtendedRequestId(String extendedRequestId) {
        this. = extendedRequestId;
    }

    
Returns any additional information retrieved in the error response.
    public Map<StringStringgetAdditionalDetails() {
        return ;
    }

    
Sets additional information about the response.
    public void setAdditionalDetails(Map<StringStringadditionalDetails) {
        this. = additionalDetails;
    }

    
Adds an entry to the additional information map.
    public void addAdditionalDetail(String keyString detail) {
        if (detail == null || detail.trim().isEmpty())
            return;
        if (this. == null) {
            this. = new HashMap<StringString>();
        }
        String additionalContent = this..get(key);
        if (additionalContent != null && !additionalContent.trim().isEmpty())
            detail = additionalContent + "-" + detail;
        if (!detail.isEmpty())
            .put(keydetail);
    }

    
Returns the original error response XML received from Amazon S3
    public String getErrorResponseXml() {
        return ;
    }

    
Sets the error response XML received from Amazon S3
    public void setErrorResponseXml(String errorResponseXml) {
        this. = errorResponseXml;
    }

    
Creates a new AmazonS3Exception object with the values set.
    public AmazonS3Exception build() {
        AmazonS3Exception s3Exception =  == null ? new AmazonS3Exception(
                ) : new AmazonS3Exception(,
                );
        s3Exception.setErrorCode();
        s3Exception.setExtendedRequestId();
        s3Exception.setStatusCode();
        s3Exception.setRequestId();
        s3Exception.setAdditionalDetails();
        s3Exception.setErrorType(errorTypeOf());
        return s3Exception;
    }

    
Returns the AWS error type information by looking at the HTTP status code in the error response. S3 error responses don't explicitly declare a sender or client fault like other AWS services, so we have to use the HTTP status code to infer this information.

Parameters:
httpResponse The HTTP error response to use to determine the right error type to set.
    private ErrorType errorTypeOf(int statusCode) {
        return statusCode >= 500 ? . : .;
    }
New to GrepCode? Check out our FAQ X