Skip to content

Commit

Permalink
return null for HTTP Not Found Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaishiyoku committed Jun 17, 2023
1 parent 5ccbc96 commit 8336798
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Carbon\Carbon;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -138,6 +139,13 @@ public static function getHttpContentTypeForUrl(string $url, Client $httpClient)
return $httpClient->get($url)->getHeaderLine('Content-Type');
} catch (ConnectException) {
return null;
} catch (ClientException $exception) {
// return null for HTTP Not Found Exceptions
if ($exception->getResponse()->getStatusCode() === 404) {
return null;
}

throw $exception;
}
}

Expand Down

0 comments on commit 8336798

Please sign in to comment.