From c3249095bc79dbe0828b39e16d6d523445b47e00 Mon Sep 17 00:00:00 2001 From: "Sudadi S.Kom" Date: Wed, 22 Nov 2023 15:33:08 +0700 Subject: [PATCH] Add catch ConnectionException handle getUpdates network connection error/disconnected --- src/Request.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Request.php b/src/Request.php index 04134f7c..8e163268 100644 --- a/src/Request.php +++ b/src/Request.php @@ -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; @@ -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() : '';