X Tutup
Skip to content

Commit f3aca42

Browse files
Eldinniejh0ker
authored andcommitted
pass errormessage to Unauthorized (python-telegram-bot#597)
1 parent ed49bdb commit f3aca42

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

telegram/error.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ def __str__(self):
6262

6363

6464
class Unauthorized(TelegramError):
65-
66-
def __init__(self):
67-
super(Unauthorized, self).__init__('Unauthorized')
65+
pass
6866

6967

7068
class InvalidToken(TelegramError):

telegram/utils/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def _request_wrapper(self, *args, **kwargs):
183183
raise NetworkError('Unknown HTTPError {0}'.format(resp.status))
184184

185185
if resp.status in (401, 403):
186-
raise Unauthorized()
186+
raise Unauthorized(message)
187187
elif resp.status == 400:
188188
raise BadRequest(message)
189189
elif resp.status == 404:

tests/test_updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def test_bootstrap_retries_success(self):
693693
def test_bootstrap_retries_unauth(self):
694694
retries = 3
695695
self._setup_updater(
696-
'', messages=0, bootstrap_retries=retries, bootstrap_err=Unauthorized())
696+
'', messages=0, bootstrap_retries=retries, bootstrap_err=Unauthorized("Unauthorized"))
697697

698698
self.assertRaises(Unauthorized, self.updater._bootstrap, retries, False, 'path', None)
699699
self.assertEqual(self.updater.bot.bootstrap_attempts, 1)

0 commit comments

Comments
 (0)
X Tutup