aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/client.py1
-rw-r--r--discord/errors.py8
-rw-r--r--discord/utils.py9
3 files changed, 8 insertions, 10 deletions
diff --git a/discord/client.py b/discord/client.py
index e4c9b247..7f3118f0 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -391,7 +391,6 @@ class Client:
else:
raise TypeError('login() takes 1 or 2 positional arguments but {} were given'.format(n))
-
@asyncio.coroutine
def logout(self):
"""|coro|
diff --git a/discord/errors.py b/discord/errors.py
index 746e1740..7d7bfa02 100644
--- a/discord/errors.py
+++ b/discord/errors.py
@@ -57,15 +57,15 @@ class HTTPException(DiscordException):
.. 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.text = text
+ self.text = message
fmt = '{0.reason} (status code: {0.status})'
- if message:
+ if len(message) < 100:
fmt = fmt + ': {1}'
super().__init__(fmt.format(self.response, message))
diff --git a/discord/utils.py b/discord/utils.py
index d9e7bddd..99c76ca5 100644
--- a/discord/utils.py
+++ b/discord/utils.py
@@ -224,18 +224,17 @@ def _verify_successful_response(response):
success = code >= 200 and code < 300
if not success:
message = None
- text = None
if response.headers['content-type'] == 'application/json':
data = yield from response.json(encoding='utf-8')
message = data.get('message')
else:
- text = yield from response.text(encoding='utf-8')
+ message = yield from response.text(encoding='utf-8')
if code == 403:
- raise Forbidden(response, message, text)
+ raise Forbidden(response, message)
elif code == 404:
- raise NotFound(response, message, text)
- raise HTTPException(response, message, text)
+ raise NotFound(response, message)
+ raise HTTPException(response, message)
def _get_mime_type_for_image(data):
if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):