mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Renamed ApiError to ApiException (Subclass of Exception)
This commit is contained in:
parent
be155afcd8
commit
b41330774b
@ -10,13 +10,13 @@ def _make_request(token, method_name, method='get', params=None, files=None):
|
|||||||
request_url = telebot.API_URL + 'bot' + token + '/' + method_name
|
request_url = telebot.API_URL + 'bot' + token + '/' + method_name
|
||||||
result = requests.request(method, request_url, params=params, files=files)
|
result = requests.request(method, request_url, params=params, files=files)
|
||||||
if result.status_code != 200:
|
if result.status_code != 200:
|
||||||
raise ApiError(method_name + r' error.', result)
|
raise ApiException(method_name + r' error.', result)
|
||||||
try:
|
try:
|
||||||
result_json = result.json()
|
result_json = result.json()
|
||||||
if not result_json['ok']:
|
if not result_json['ok']:
|
||||||
raise ApiError(method_name, ' failed, result=' + result_json)
|
raise ApiException(method_name, ' failed, result=' + result_json)
|
||||||
except:
|
except:
|
||||||
raise ApiError(method_name + r' error.', result)
|
raise ApiException(method_name + r' error.', result)
|
||||||
return result_json['result']
|
return result_json['result']
|
||||||
|
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ def convert_markup(markup):
|
|||||||
return markup
|
return markup
|
||||||
|
|
||||||
|
|
||||||
class ApiError(Exception):
|
class ApiException(Exception):
|
||||||
def __init__(self, message, result):
|
def __init__(self, message, result):
|
||||||
super(ApiError, self).__init__(message)
|
super(ApiException, self).__init__(message)
|
||||||
self.result = result
|
self.result = result
|
||||||
|
Loading…
Reference in New Issue
Block a user