Skip to content

Commit 9e9085d

Browse files
committed
Changed return type for sendRequest
1 parent 956d6d5 commit 9e9085d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/Telegram/Bot.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private function isValidUpdatesMethod(): void{
6969
*
7070
* @throws TelegramException If an error occurs during the request (in non-production mode).
7171
*/
72-
private function sendRequest(string $method, array|object|null $arguments = null, $timeout = 10): ?TelegramResponse{
72+
private function sendRequest(string $method, array|object|null $arguments = null, $timeout = 10): TelegramResponse{
7373
$telegram_url = "https://api.telegram.org/bot" . $this->token . "/$method";
7474
$client = new Guzzle(['timeout' => $timeout]);
7575

@@ -82,16 +82,21 @@ private function sendRequest(string $method, array|object|null $arguments = null
8282

8383
return new TelegramResponse([
8484
"statusCode" => $response->getStatusCode(),
85-
"body" => $response->body
85+
"body" => $response->body,
86+
"error" => null
8687
]);
8788

8889
} catch(RequestException $e){
8990
if(!$this->isProduction)
9091
throw new TelegramException($e->getMessage());
9192

92-
error_log($e->getMessage());
93+
$response = $e->getResponse();
9394

94-
return null;
95+
return new TelegramResponse([
96+
"statusCode" => $response->getStatusCode() ?? null,
97+
"body" => $response->getBody()->getContents() ?? null,
98+
"error" => $e
99+
]);
95100
}
96101
}
97102

0 commit comments

Comments
 (0)