| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*******************************************************************************
|
|
|
3 |
* Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
*
|
|
|
6 |
* You may not use this file except in compliance with the License.
|
|
|
7 |
* You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
|
|
|
8 |
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
9 |
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
|
10 |
* specific language governing permissions and limitations under the License.
|
|
|
11 |
* *****************************************************************************
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* Checkout By Service Exception provides details of errors
|
|
|
18 |
* returned by Checkout By Service service
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
class CheckoutByAmazon_Service_Exception extends Exception
|
|
|
22 |
|
|
|
23 |
{
|
|
|
24 |
/** @var string */
|
|
|
25 |
private $_message = null;
|
|
|
26 |
/** @var int */
|
|
|
27 |
private $_statusCode = -1;
|
|
|
28 |
/** @var string */
|
|
|
29 |
private $_errorCode = null;
|
|
|
30 |
/** @var string */
|
|
|
31 |
private $_errorType = null;
|
|
|
32 |
/** @var string */
|
|
|
33 |
private $_requestId = null;
|
|
|
34 |
/** @var string */
|
|
|
35 |
private $_xml = null;
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Constructs CheckoutByAmazon_Service_Exception
|
|
|
40 |
* @param array $ErrorInfo details of exception.
|
|
|
41 |
* Keys are:
|
|
|
42 |
* <ul>
|
|
|
43 |
* <li>Message - (string) text message for an exception</li>
|
|
|
44 |
* <li>StatusCode - (int) HTTP status code at the time of exception</li>
|
|
|
45 |
* <li>ErrorCode - (string) specific error code returned by the service</li>
|
|
|
46 |
* <li>ErrorType - (string) Possible types: Sender, Receiver or Unknown</li>
|
|
|
47 |
* <li>RequestId - (string) request id returned by the service</li>
|
|
|
48 |
* <li>XML - (string) compete xml response at the time of exception</li>
|
|
|
49 |
* <li>Exception - (Exception) inner exception if any</li>
|
|
|
50 |
* </ul>
|
|
|
51 |
*
|
|
|
52 |
*/
|
|
|
53 |
public function __construct(array $ErrorInfo = array())
|
|
|
54 |
{
|
|
|
55 |
$this->_message = $ErrorInfo["Message"];
|
|
|
56 |
parent::__construct($this->_message);
|
|
|
57 |
if (array_key_exists("Exception", $ErrorInfo)) {
|
|
|
58 |
$exception = $ErrorInfo["Exception"];
|
|
|
59 |
if ($Exception instanceof CheckoutByAmazon_Service_Exception) {
|
|
|
60 |
$this->_statusCode = $exception->getStatusCode();
|
|
|
61 |
$this->_errorCode = $exception->getErrorCode();
|
|
|
62 |
$this->_errorType = $exception->getErrorType();
|
|
|
63 |
$this->_requestId = $exception->getRequestId();
|
|
|
64 |
$this->_xml= $exception->getXML();
|
|
|
65 |
}
|
|
|
66 |
} else {
|
|
|
67 |
$this->_statusCode = $ErrorInfo["StatusCode"];
|
|
|
68 |
$this->_errorCode = $ErrorInfo["ErrorCode"];
|
|
|
69 |
$this->_errorType = $ErrorInfo["ErrorType"];
|
|
|
70 |
$this->_requestId = $ErrorInfo["RequestId"];
|
|
|
71 |
$this->_xml= $ErrorInfo["XML"];
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Gets error type returned by the service if available.
|
|
|
77 |
*
|
|
|
78 |
* @return string Error Code returned by the service
|
|
|
79 |
*/
|
|
|
80 |
public function getErrorCode(){
|
|
|
81 |
return $this->_errorCode;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Gets error type returned by the service.
|
|
|
86 |
*
|
|
|
87 |
* @return string Error Type returned by the service.
|
|
|
88 |
* Possible types: Sender, Receiver or Unknown
|
|
|
89 |
*/
|
|
|
90 |
public function getErrorType(){
|
|
|
91 |
return $this->_errorType;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
/**
|
|
|
96 |
* Gets error message
|
|
|
97 |
*
|
|
|
98 |
* @return string Error message
|
|
|
99 |
*/
|
|
|
100 |
public function getErrorMessage() {
|
|
|
101 |
return $this->_message;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
/**
|
|
|
105 |
* Gets status code returned by the service if available. If status
|
|
|
106 |
* code is set to -1, it means that status code was unavailable at the
|
|
|
107 |
* time exception was thrown
|
|
|
108 |
*
|
|
|
109 |
* @return int status code returned by the service
|
|
|
110 |
*/
|
|
|
111 |
public function getStatusCode() {
|
|
|
112 |
return $this->_statusCode;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
/**
|
|
|
116 |
* Gets XML returned by the service if available.
|
|
|
117 |
*
|
|
|
118 |
* @return string XML returned by the service
|
|
|
119 |
*/
|
|
|
120 |
public function getXML() {
|
|
|
121 |
return $this->_xml;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
/**
|
|
|
125 |
* Gets Request ID returned by the service if available.
|
|
|
126 |
*
|
|
|
127 |
* @return string Request ID returned by the service
|
|
|
128 |
*/
|
|
|
129 |
public function getRequestId() {
|
|
|
130 |
return $this->_requestId;
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
?>
|