Skip to content

Commit

Permalink
Catch guzzle errors in tasotahelper (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse committed Sep 18, 2022
1 parent 2c1ca85 commit 7a403a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tasmoadmin/src/Helper/TasmotaHelper.php
Expand Up @@ -3,6 +3,7 @@
namespace TasmoAdmin\Helper;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use InvalidArgumentException;
use Parsedown;
use TasmoAdmin\Update\AutoFirmwareResult;
Expand Down Expand Up @@ -106,8 +107,12 @@ private function getLatestRelease(): TasmoFirmwareResult

private function getContents(string $url): string
{
$url = "${url}?r=" . time();
return $this->client->get($url)->getBody()->getContents();
try {
$url = "${url}?r=" . time();
return $this->client->get($url)->getBody()->getContents();
} catch (GuzzleException $exception) {
return sprintf('Failed to load %s - %s', $url, $exception->getMessage());
}
}

private function replaceIssuesWithUrls(string $content): string
Expand Down

0 comments on commit 7a403a6

Please sign in to comment.