Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch guzzle errors in tasotahelper #664

Merged
merged 1 commit into from Sep 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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