From d65691ae6992d20d4f069742d6950e83124fdf21 Mon Sep 17 00:00:00 2001 From: Ne-Lexa Date: Mon, 3 Oct 2022 17:53:06 +0300 Subject: [PATCH] fixed 404 error --- src/GPlayApps.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/GPlayApps.php b/src/GPlayApps.php index d07c1ff..04c5c38 100644 --- a/src/GPlayApps.php +++ b/src/GPlayApps.php @@ -13,6 +13,7 @@ namespace Nelexa\GPlay; +use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Promise\EachPromise; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Psr7\Query; @@ -1093,14 +1094,21 @@ protected function fetchAppsFromClusterPages($category, ?Enum\AgeEnum $age, int $apps = []; $count = 0; foreach ($this->getClusterPages($category, $age) as $clusterPage) { - foreach ($this->getClusterApps($clusterPage->getUrl()) as $app) { - if (!isset($apps[$app->getId()])) { - $apps[$app->getId()] = $app; - ++$count; - if ($count === $limit) { - break 2; + try { + foreach ($this->getClusterApps($clusterPage->getUrl()) as $app) { + if (!isset($apps[$app->getId()])) { + $apps[$app->getId()] = $app; + ++$count; + if ($count === $limit) { + break 2; + } } } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null || $response->getStatusCode() !== 404) { + throw $e; + } } }