mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-14 19:48:57 +01:00
add http error exception handling
This commit is contained in:
parent
adb446abf6
commit
5b05bcc8f2
1 changed files with 6 additions and 4 deletions
|
@ -5,11 +5,11 @@ import json
|
|||
try:
|
||||
from urllib.request import urlopen, Request
|
||||
from urllib.parse import quote
|
||||
from urllib.error import URLError
|
||||
from urllib.error import URLError, HTTPError
|
||||
except ImportError:
|
||||
from urllib2 import urlopen, Request
|
||||
from urllib import quote
|
||||
from urllib2 import URLError
|
||||
from urllib2 import URLError, HTTPError
|
||||
|
||||
|
||||
class Botan(object):
|
||||
|
@ -38,7 +38,9 @@ class Botan(object):
|
|||
if response.getcode() != 200:
|
||||
return False
|
||||
return True
|
||||
except URLError as error:
|
||||
except HTTPError as error:
|
||||
print('botan track error ' + str(error.code) + ':' + error.reason)
|
||||
print(url)
|
||||
return False
|
||||
except URLError as error:
|
||||
print('botan track error ' + error.reason)
|
||||
return False
|
||||
|
|
Loading…
Add table
Reference in a new issue