@@ -149,6 +149,8 @@ public static function request($client, $method, $url, $params = null, $beta = f
149149 * @param mixed $params
150150 * @param bool $beta
151151 * @return array
152+ * @throws HttpException
153+ * @throws TimeoutException
152154 */
153155 private static function requestRaw ($ client , $ method , $ url , $ params , $ beta = false )
154156 {
@@ -201,6 +203,7 @@ private static function requestRaw($client, $method, $url, $params, $beta = fals
201203 * @param string $httpBody
202204 * @param int $httpStatus
203205 * @return mixed
206+ * @throws JsonException
204207 */
205208 public static function interpretResponse ($ httpBody , $ httpStatus )
206209 {
@@ -223,6 +226,19 @@ public static function interpretResponse($httpBody, $httpStatus)
223226 * @param string $httpBody
224227 * @param int $httpStatus
225228 * @param array $response
229+ * @throws GatewayTimeoutException
230+ * @throws InternalServerException
231+ * @throws InvalidRequestException
232+ * @throws JsonException
233+ * @throws MethodNotAllowedException
234+ * @throws NotFoundException
235+ * @throws PaymentException
236+ * @throws RateLimitException
237+ * @throws RedirectException
238+ * @throws ServiceUnavailableException
239+ * @throws TimeoutException
240+ * @throws UnauthorizedException
241+ * @throws UnknownApiException
226242 */
227243 public static function handleApiError ($ httpBody , $ httpStatus , $ response )
228244 {
@@ -242,54 +258,79 @@ public static function handleApiError($httpBody, $httpStatus, $response)
242258 switch ($ httpStatus ) {
243259 case 100 :
244260 $ errorType = UnknownApiException::class;
261+ break ;
245262 case 101 :
246263 $ errorType = UnknownApiException::class;
264+ break ;
247265 case 102 :
248266 $ errorType = UnknownApiException::class;
267+ break ;
249268 case 103 :
250269 $ errorType = UnknownApiException::class;
270+ break ;
251271 case 300 :
252272 $ errorType = RedirectException::class;
273+ break ;
253274 case 301 :
254275 $ errorType = RedirectException::class;
276+ break ;
255277 case 302 :
256278 $ errorType = RedirectException::class;
279+ break ;
257280 case 303 :
258281 $ errorType = RedirectException::class;
282+ break ;
259283 case 304 :
260284 $ errorType = RedirectException::class;
285+ break ;
261286 case 305 :
262287 $ errorType = RedirectException::class;
288+ break ;
263289 case 306 :
264290 $ errorType = RedirectException::class;
291+ break ;
265292 case 307 :
266293 $ errorType = RedirectException::class;
294+ break ;
267295 case 308 :
268296 $ errorType = RedirectException::class;
297+ break ;
269298 case 401 :
270299 $ errorType = UnauthorizedException::class;
300+ break ;
271301 case 402 :
272302 $ errorType = PaymentException::class;
303+ break ;
273304 case 403 :
274305 $ errorType = UnauthorizedException::class;
306+ break ;
275307 case 404 :
276308 $ errorType = NotFoundException::class;
309+ break ;
277310 case 405 :
278311 $ errorType = MethodNotAllowedException::class;
312+ break ;
279313 case 408 :
280314 $ errorType = TimeoutException::class;
315+ break ;
281316 case 422 :
282317 $ errorType = InvalidRequestException::class;
318+ break ;
283319 case 429 :
284320 $ errorType = RateLimitException::class;
321+ break ;
285322 case 500 :
286323 $ errorType = InternalServerException::class;
324+ break ;
287325 case 503 :
288326 $ errorType = ServiceUnavailableException::class;
327+ break ;
289328 case 504 :
290329 $ errorType = GatewayTimeoutException::class;
330+ break ;
291331 default :
292332 $ errorType = UnknownApiException::class;
333+ break ;
293334 }
294335
295336 throw new $ errorType ($ message , $ httpStatus , $ httpBody );
0 commit comments