1 | <?php |
||
30 | class RequestException extends Exception { |
||
31 | |||
32 | /** |
||
33 | * @var ResponseInterface|null |
||
34 | */ |
||
35 | protected $response; |
||
36 | |||
37 | /** |
||
38 | * @var int|null |
||
39 | */ |
||
40 | protected $errorCode; |
||
41 | |||
42 | /** |
||
43 | * @var int|null |
||
44 | */ |
||
45 | protected $errorSubcode; |
||
46 | |||
47 | /** |
||
48 | * @var string|null |
||
49 | */ |
||
50 | protected $errorMessage; |
||
51 | |||
52 | /** |
||
53 | * @var string|null |
||
54 | */ |
||
55 | protected $errorUserTitle; |
||
56 | |||
57 | /** |
||
58 | * @var string|null |
||
59 | */ |
||
60 | protected $errorUserMessage; |
||
61 | |||
62 | /** |
||
63 | * @var int|null |
||
64 | */ |
||
65 | protected $errorType; |
||
66 | |||
67 | /** |
||
68 | * @var array|null |
||
69 | */ |
||
70 | protected $errorBlameFieldSpecs; |
||
71 | |||
72 | /** |
||
73 | * @param ResponseInterface $response |
||
74 | */ |
||
75 | 8 | public function __construct(ResponseInterface $response) { |
|
76 | 8 | $this->response = $response; |
|
77 | 8 | $error_data = static::getErrorData($response); |
|
78 | |||
79 | 8 | parent::__construct($error_data['message'], $error_data['code']); |
|
80 | |||
81 | 8 | $this->errorSubcode = $error_data['error_subcode']; |
|
82 | 8 | $this->errorUserTitle = $error_data['error_user_title']; |
|
83 | 8 | $this->errorUserMessage = $error_data['error_user_msg']; |
|
84 | 8 | $this->errorBlameFieldSpecs = $error_data['error_blame_field_specs']; |
|
85 | 8 | } |
|
86 | |||
87 | /** |
||
88 | * @return ResponseInterface|null |
||
89 | */ |
||
90 | public function getResponse() { |
||
91 | return $this->response; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @param array $array |
||
96 | * @param string|int $key |
||
97 | * @param mixed $default |
||
98 | * @return mixed |
||
99 | */ |
||
100 | 8 | protected static function idx(array $array, $key, $default = null) { |
|
105 | |||
106 | /** |
||
107 | * @param ResponseInterface $response |
||
108 | * @return array |
||
109 | */ |
||
110 | 8 | protected static function getErrorData(ResponseInterface $response) { |
|
130 | |||
131 | /** |
||
132 | * Process an error payload from the Graph API and return the appropriate |
||
133 | * exception subclass. |
||
134 | * @param ResponseInterface $response |
||
135 | * @return RequestException |
||
136 | */ |
||
137 | 7 | public static function create(ResponseInterface $response) { |
|
163 | |||
164 | /** |
||
165 | * @return int |
||
166 | */ |
||
167 | 1 | public function getHttpStatusCode() { |
|
170 | |||
171 | /** |
||
172 | * @return int|null |
||
173 | */ |
||
174 | 1 | public function getErrorSubcode() { |
|
177 | |||
178 | /** |
||
179 | * @return string|null |
||
180 | */ |
||
181 | 1 | public function getErrorUserTitle() { |
|
184 | |||
185 | /** |
||
186 | * @return string|null |
||
187 | */ |
||
188 | 1 | public function getErrorUserMessage() { |
|
191 | |||
192 | /** |
||
193 | * @return array|null |
||
194 | */ |
||
195 | 1 | public function getErrorBlameFieldSpecs() { |
|
198 | |||
199 | /** |
||
200 | * @return bool |
||
201 | */ |
||
202 | public function isTransient() { |
||
213 | } |
||
214 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.