コード例 #1
0
 /**
  * Checks the response for Http errors.
  *
  * @param Response $response
  * @throws \LeagueWrap\Response\Http400
  * @throws \LeagueWrap\Response\Http401
  * @throws \LeagueWrap\Response\Http402
  * @throws \LeagueWrap\Response\Http403
  * @throws \LeagueWrap\Response\Http404
  * @throws \LeagueWrap\Response\Http405
  * @throws \LeagueWrap\Response\Http406
  * @throws \LeagueWrap\Response\Http407
  * @throws \LeagueWrap\Response\Http408
  * @throws \LeagueWrap\Response\Http429
  * @throws \LeagueWrap\Response\Http500
  * @throws \LeagueWrap\Response\Http501
  * @throws \LeagueWrap\Response\Http502
  * @throws \LeagueWrap\Response\Http503
  * @throws \LeagueWrap\Response\Http504
  * @throws \LeagueWrap\Response\Http505
  */
 protected function checkResponseErrors(Response $response)
 {
     $code = $response->getCode();
     if (intval($code / 100) != 2) {
         // we have an error!
         $message = "Http Error.";
         if (isset($this->responseErrors[$code])) {
             $message = trim($this->responseErrors[$code]);
         }
         $class = 'LeagueWrap\\Response\\Http' . $code;
         throw new $class($message, $code);
     }
 }
コード例 #2
0
ファイル: AbstractApi.php プロジェクト: paquettg/leaguewrap
 /**
  * Checks the response for Http errors.
  *
  * @param Response $response
  * @throws \LeagueWrap\Response\Http400
  * @throws \LeagueWrap\Response\Http401
  * @throws \LeagueWrap\Response\Http402
  * @throws \LeagueWrap\Response\Http403
  * @throws \LeagueWrap\Response\Http404
  * @throws \LeagueWrap\Response\Http405
  * @throws \LeagueWrap\Response\Http406
  * @throws \LeagueWrap\Response\Http407
  * @throws \LeagueWrap\Response\Http408
  * @throws \LeagueWrap\Response\Http429
  * @throws \LeagueWrap\Response\Http500
  * @throws \LeagueWrap\Response\Http501
  * @throws \LeagueWrap\Response\Http502
  * @throws \LeagueWrap\Response\Http503
  * @throws \LeagueWrap\Response\Http504
  * @throws \LeagueWrap\Response\Http505
  * @throws \LeagueWrap\Response\UnderlyingServiceRateLimitReached
  */
 protected function checkResponseErrors(Response $response)
 {
     $code = $response->getCode();
     if ($code === 429 && !$response->hasHeader('Retry-After')) {
         throw Response\UnderlyingServiceRateLimitReached::withResponse("Did not receive 'X-Rate-Limit-Type' and 'Retry-After' headers. " . "See https://developer.riotgames.com/docs/rate-limiting for more details", $response);
     }
     if (intval($code / 100) != 2) {
         // we have an error!
         $message = "Http Error.";
         if (isset($this->responseErrors[$code])) {
             $message = trim($this->responseErrors[$code]);
         }
         $class = 'LeagueWrap\\Response\\Http' . $code;
         if (class_exists($class) && is_subclass_of($class, ResponseException::class)) {
             throw $class::withResponse($message, $response);
         }
     }
 }