Skip to content

Commit

Permalink
Merge pull request #1433 from sudadi/develop
Browse files Browse the repository at this point in the history
Add catch ConnectionException
  • Loading branch information
noplanman committed Jan 3, 2024
2 parents 26433b3 + c324909 commit e243fc1
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 e243fc1

Please sign in to comment.