/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  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.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 
 *  Amazon A2S Java Library
 *  API Version: 2007-10-29
 *  Generated: Thu Jan 10 05:27:32 PST 2008 
 
 */



package com.amazonaws.a2s;

/**
 * Amazon A2S  Exception provides details of errors 
 * returned by Amazon A2S  service
 *
 */
public class AmazonA2SException extends Exception {
    
    private String message = null;
    private int statusCode = -1;
    private String errorCode = null;
    private String requestId = null;
    private String xml = null;
    
    
    /**
     * Constructs AmazonA2SException with message
     @param message
     *          Overview of error
     */
    public AmazonA2SException(String message) {
        this.message = message;
    }
    
    /**
     * Constructs AmazonA2SException with message and status code
     @param message
     *          Overview of error
     @param statusCode
     *          HTTP status code for error response
     */
    public AmazonA2SException(String message, int statusCode) {
        this.message = message;
        this.statusCode = statusCode;
    }
    
    /**
     * Constructs AmazonA2SException with wrapped exception
     @param t
     *          wrapped exception
     */
    public AmazonA2SException(Throwable t) {
        super(t);
        if (instanceof AmazonA2SException) {
            AmazonA2SException ex = (AmazonA2SException)t;
            this.message = ex.getMessage();
            this.statusCode = ex.getStatusCode();
            this.errorCode = ex.getErrorCode();
            this.requestId = ex.getRequestId();
            this.xml = ex.getXML();
        }
    }
    
    /**
     * Constructs AmazonA2SException with message and wrapped exception
     @param message
     *          Overview of error
     @param t
     *          wrapped exception
     */
    public AmazonA2SException(String message, Throwable t) {
        super(message, t);
        this.message = message;
    }
    
    
    /**
     * Constructs AmazonA2SException with information available from service
     @param message
     *          Overview of error
     @param statusCode
     *          HTTP status code for error response
     @param errorCode
     *          Error Code returned by the service
     @param requestId
     *          Request ID returned by the service
     @param xml
     *          Compete xml found in response
     */
    public AmazonA2SException(String message, int statusCode, String errorCode,  String requestId,  String xml) {
        
        this.message = message;
        this.statusCode = statusCode;
        this.errorCode = errorCode;
        this.requestId = requestId;
        this.xml = xml;
    }
    
    /**
     * Gets error code returned by the service if available.
     *
     @return Error Code returned by the service
     */
    public String getErrorCode(){
        return errorCode;
    }
    
    
    /**
     * Gets error message
     *
     @return Error message
     */
    public String getMessage() {
        return message;
    }
    
    /**
     * Gets status code returned by the service if available. If status
     * code is set to -1, it means that status code was unavailable at the
     * time exception was thrown
     *
     @return status code returned by the service
     */
    public int getStatusCode() {
        return statusCode;
    }
    
    /**
     * Gets XML returned by the service if available.
     *
     @return XML returned by the service
     */
    public String getXML() {
        return xml;
    }
    
    /**
     * Gets Request ID returned by the service if available.
     *
     @return Request ID returned by the service
     */
    public String getRequestId() {
        return requestId;
    }
}