Change HTTPException to only take a single parameter.
This commit is contained in:
parent
5f9ed8c9d2
commit
fa36a449e9
@ -391,7 +391,6 @@ class Client:
|
|||||||
else:
|
else:
|
||||||
raise TypeError('login() takes 1 or 2 positional arguments but {} were given'.format(n))
|
raise TypeError('login() takes 1 or 2 positional arguments but {} were given'.format(n))
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def logout(self):
|
def logout(self):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
@ -57,15 +57,15 @@ class HTTPException(DiscordException):
|
|||||||
|
|
||||||
.. attribute:: text
|
.. attribute:: text
|
||||||
|
|
||||||
The text of the response if it wasn't JSON. Could be None.
|
The text of the error. Could be an empty string.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, response, message=None, text=None):
|
def __init__(self, response, message):
|
||||||
self.response = response
|
self.response = response
|
||||||
self.text = text
|
self.text = message
|
||||||
|
|
||||||
fmt = '{0.reason} (status code: {0.status})'
|
fmt = '{0.reason} (status code: {0.status})'
|
||||||
if message:
|
if len(message) < 100:
|
||||||
fmt = fmt + ': {1}'
|
fmt = fmt + ': {1}'
|
||||||
|
|
||||||
super().__init__(fmt.format(self.response, message))
|
super().__init__(fmt.format(self.response, message))
|
||||||
|
@ -224,18 +224,17 @@ def _verify_successful_response(response):
|
|||||||
success = code >= 200 and code < 300
|
success = code >= 200 and code < 300
|
||||||
if not success:
|
if not success:
|
||||||
message = None
|
message = None
|
||||||
text = None
|
|
||||||
if response.headers['content-type'] == 'application/json':
|
if response.headers['content-type'] == 'application/json':
|
||||||
data = yield from response.json(encoding='utf-8')
|
data = yield from response.json(encoding='utf-8')
|
||||||
message = data.get('message')
|
message = data.get('message')
|
||||||
else:
|
else:
|
||||||
text = yield from response.text(encoding='utf-8')
|
message = yield from response.text(encoding='utf-8')
|
||||||
|
|
||||||
if code == 403:
|
if code == 403:
|
||||||
raise Forbidden(response, message, text)
|
raise Forbidden(response, message)
|
||||||
elif code == 404:
|
elif code == 404:
|
||||||
raise NotFound(response, message, text)
|
raise NotFound(response, message)
|
||||||
raise HTTPException(response, message, text)
|
raise HTTPException(response, message)
|
||||||
|
|
||||||
def _get_mime_type_for_image(data):
|
def _get_mime_type_for_image(data):
|
||||||
if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):
|
if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user