File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments