pass errormessage to Unauthorized (#597)

This commit is contained in:
Eldinnie 2017-05-12 17:38:36 +02:00 committed by Jannes Höke
parent ed49bdb19c
commit f3aca42e69
3 changed files with 3 additions and 5 deletions

View file

@ -62,9 +62,7 @@ class TelegramError(Exception):
class Unauthorized(TelegramError):
def __init__(self):
super(Unauthorized, self).__init__('Unauthorized')
pass
class InvalidToken(TelegramError):

View file

@ -183,7 +183,7 @@ class Request(object):
raise NetworkError('Unknown HTTPError {0}'.format(resp.status))
if resp.status in (401, 403):
raise Unauthorized()
raise Unauthorized(message)
elif resp.status == 400:
raise BadRequest(message)
elif resp.status == 404:

View file

@ -693,7 +693,7 @@ class UpdaterTest(BaseTest, unittest.TestCase):
def test_bootstrap_retries_unauth(self):
retries = 3
self._setup_updater(
'', messages=0, bootstrap_retries=retries, bootstrap_err=Unauthorized())
'', messages=0, bootstrap_retries=retries, bootstrap_err=Unauthorized("Unauthorized"))
self.assertRaises(Unauthorized, self.updater._bootstrap, retries, False, 'path', None)
self.assertEqual(self.updater.bot.bootstrap_attempts, 1)