Skip to content

Commit

Permalink
Add catch ConnectionException
Browse files Browse the repository at this point in the history
handle getUpdates network connection error/disconnected
  • Loading branch information
sudadi authored Nov 22, 2023
1 parent 26433b3 commit c324909
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Stream;
use Longman\TelegramBot\Entities\File;
Expand Down Expand Up @@ -603,6 +604,9 @@ public static function execute(string $action, array $data = []): string
$request_params
);
$result = (string) $response->getBody();
} catch (ConnectException $e) {
$response = null;
$result = $e->getMessage();
} catch (RequestException $e) {
$response = null;
$result = $e->getResponse() ? (string) $e->getResponse()->getBody() : '';
Expand Down

0 comments on commit c324909

Please sign in to comment.