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) { |
|
134 | |||
135 | /** |
||
136 | * Process an error payload from the Graph API and return the appropriate |
||
137 | * exception subclass. |
||
138 | * @param ResponseInterface $response |
||
139 | * @return RequestException |
||
140 | */ |
||
141 | 7 | public static function create(ResponseInterface $response) { |
|
167 | |||
168 | /** |
||
169 | * @return int |
||
170 | */ |
||
171 | 1 | public function getHttpStatusCode() { |
|
174 | |||
175 | /** |
||
176 | * @return int|null |
||
177 | */ |
||
178 | 1 | public function getErrorSubcode() { |
|
181 | |||
182 | /** |
||
183 | * @return string|null |
||
184 | */ |
||
185 | 1 | public function getErrorUserTitle() { |
|
188 | |||
189 | /** |
||
190 | * @return string|null |
||
191 | */ |
||
192 | 1 | public function getErrorUserMessage() { |
|
195 | |||
196 | /** |
||
197 | * @return array|null |
||
198 | */ |
||
199 | 1 | public function getErrorBlameFieldSpecs() { |
|
202 | |||
203 | /** |
||
204 | * @return bool |
||
205 | */ |
||
206 | public function isTransient() { |
||
217 | } |
||
218 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.