Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12451 kshitij.so 1
/******************************************************************************* 
2
 *  Copyright 2009 Amazon Services.
3
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
4
 *  
5
 *  You may not use this file except in compliance with the License. 
6
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
7
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
8
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
9
 *  specific language governing permissions and limitations under the License.
10
 * ***************************************************************************** 
11
 *
12
 *  Marketplace Web Service Java Library
13
 *  API Version: 2009-01-01
14
 *  Generated: Wed Feb 18 13:28:48 PST 2009 
15
 * 
16
 */
17
 
18
 
19
 
20
package com.amazonaws.mws;
21
 
22
import com.amazonaws.mws.model.ResponseHeaderMetadata;
23
 
24
/**
25
 * Marketplace Web Service  Exception provides details of errors 
26
 * returned by Marketplace Web Service  service
27
 *
28
 */
29
@SuppressWarnings("serial")
30
public class MarketplaceWebServiceException extends Exception {
31
 
32
    private String message = null;
33
    private int statusCode = -1;
34
    private String errorCode = null;
35
    private String errorType = null;
36
    private String requestId = null;
37
    private String xml = null;
38
    private ResponseHeaderMetadata responseHeaderMetadata = null;
39
 
40
 
41
    /**
42
     * Constructs MarketplaceWebServiceException with message
43
     * @param message
44
     *          Overview of error
45
     */
46
    public MarketplaceWebServiceException(String message) {
47
        this.message = message;
48
    }
49
 
50
    /**
51
     * Constructs MarketplaceWebServiceException with message and status code
52
     * @param message
53
     *          Overview of error
54
     * @param statusCode
55
     *          HTTP status code for error response
56
     */
57
    public MarketplaceWebServiceException(String message, int statusCode, ResponseHeaderMetadata metadata) {
58
        this.message = message;
59
        this.statusCode = statusCode;
60
        this.responseHeaderMetadata = metadata;
61
    }
62
 
63
    /**
64
     * Constructs MarketplaceWebServiceException with wrapped exception
65
     * @param t
66
     *          wrapped exception
67
     */
68
    public MarketplaceWebServiceException(Throwable t) {
69
        super(t);
70
        if (t instanceof MarketplaceWebServiceException) {
71
            MarketplaceWebServiceException ex = (MarketplaceWebServiceException)t;
72
            this.message = ex.getMessage();
73
            this.statusCode = ex.getStatusCode();
74
            this.errorCode = ex.getErrorCode();
75
            this.errorType = ex.getErrorType();
76
            this.requestId = ex.getRequestId();
77
            this.xml = ex.getXML();
78
        }
79
    }
80
 
81
    /**
82
     * Constructs MarketplaceWebServiceException with message and wrapped exception
83
     * @param message
84
     *          Overview of error
85
     * @param t
86
     *          wrapped exception
87
     */
88
    public MarketplaceWebServiceException(String message, Throwable t) {
89
        super(message, t);
90
        this.message = message;
91
    }
92
 
93
 
94
    /**
95
     * Constructs MarketplaceWebServiceException with information available from service
96
     * @param message
97
     *          Overview of error
98
     * @param statusCode
99
     *          HTTP status code for error response
100
     * @param errorCode
101
     *          Error Code returned by the service
102
     * @param errorType
103
     *          Error type. Possible types:  Sender, Receiver or Unknown
104
     * @param requestId
105
     *          Request ID returned by the service
106
     * @param xml
107
     *          Compete xml found in response
108
     */
109
    public MarketplaceWebServiceException(String message, int statusCode, String errorCode, String errorType, String requestId,  String xml, ResponseHeaderMetadata metadata) {
110
 
111
        this.message = message;
112
        this.statusCode = statusCode;
113
        this.errorCode = errorCode;
114
        this.errorType = errorType;
115
        this.requestId = requestId;
116
        this.xml = xml;
117
        this.responseHeaderMetadata = metadata;
118
    }
119
 
120
    /**
121
     * Gets error code returned by the service if available.
122
     *
123
     * @return Error Code returned by the service
124
     */
125
    public String getErrorCode(){
126
        return errorCode;
127
    }
128
 
129
    /**
130
     * Gets error type returned by the service if available.
131
     *
132
     * @return Error Type returned by the service
133
     */
134
    public String getErrorType(){
135
        return errorType;
136
    }
137
 
138
    /**
139
     * Gets error message
140
     *
141
     * @return Error message
142
     */
143
    @Override
144
    public String getMessage() {
145
        return message;
146
    }
147
 
148
    /**
149
     * Gets status code returned by the service if available. If status
150
     * code is set to -1, it means that status code was unavailable at the
151
     * time exception was thrown
152
     *
153
     * @return status code returned by the service
154
     */
155
    public int getStatusCode() {
156
        return statusCode;
157
    }
158
 
159
    /**
160
     * Gets XML returned by the service if available.
161
     *
162
     * @return XML returned by the service
163
     */
164
    public String getXML() {
165
        return xml;
166
    }
167
 
168
    /**
169
     * Gets Request ID returned by the service if available.
170
     *
171
     * @return Request ID returned by the service
172
     */
173
    public String getRequestId() {
174
        return requestId;
175
    }
176
 
177
    public void setResponseHeaderMetadata(ResponseHeaderMetadata responseHeaderMetadata) {
178
      this.responseHeaderMetadata = responseHeaderMetadata;
179
    }
180
 
181
    public ResponseHeaderMetadata getResponseHeaderMetadata() {
182
      return responseHeaderMetadata;
183
    }
184
}