Unauthorized is HTTP code 401

I am not certain where the older 403 came from, but for now going to
leave it as is
This commit is contained in:
Noam Meltzer 2016-02-06 12:37:56 +02:00
parent 9c81b810f2
commit 7ebbc60694

View file

@ -79,9 +79,11 @@ def _try_except_req(func):
except HTTPError as error:
# `HTTPError` inherits from `URLError` so `HTTPError` handling must
# come first.
if error.getcode() == 403:
errcode = error.getcode()
if errcode in (401, 403):
raise Unauthorized()
if error.getcode() == 502:
if errcode == 502:
raise TelegramError('Bad Gateway')
try:
@ -89,7 +91,7 @@ def _try_except_req(func):
except ValueError:
message = 'Unknown HTTPError {0}'.format(error.getcode())
raise NetworkError(message)
raise NetworkError('{0} ({1})'.format(message, errcode))
except URLError as error:
raise NetworkError('URLError: {0!r}'.format(error))