From 1bb98483c282591766fcfccf04ec85749e4db7cc Mon Sep 17 00:00:00 2001 From: "Mr. Dog" <68982655+mrpes@users.noreply.github.com> Date: Tue, 4 Aug 2020 05:34:13 +0500 Subject: [PATCH] Update apihelper.py --- telebot/apihelper.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 3f3ddfd..964104a 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -127,14 +127,15 @@ def _check_result(method_name, result): try: result_json = result.json() except: - raise ApiInvalidJSONException(method_name, result) + if result.status_code != 200: + raise ApiHTTPException(method_name, result) + else: + raise ApiInvalidJSONException(method_name, result) + else: if not result_json['ok']: raise ApiTelegramException(method_name, result, result_json) - elif result.status_code != 200: - raise ApiHTTPException(method_name, result) - return result_json