aboutsummaryrefslogtreecommitdiff
path: root/discord/errors.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-06-12 20:36:07 -0400
committerRapptz <[email protected]>2016-06-12 20:36:07 -0400
commite8c32c542eb4a816db44a94c8af6578f4e9cb9e3 (patch)
treec9b9c043d8fcbf96d792ca69ca9420aea4a4e04d /discord/errors.py
parentRewrite HTTP handling significantly. (diff)
downloaddiscord.py-e8c32c542eb4a816db44a94c8af6578f4e9cb9e3.tar.xz
discord.py-e8c32c542eb4a816db44a94c8af6578f4e9cb9e3.zip
Make HTTPException get the error JSON's message attribute.
Diffstat (limited to 'discord/errors.py')
-rw-r--r--discord/errors.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/discord/errors.py b/discord/errors.py
index 7d7bfa02..46d5e940 100644
--- a/discord/errors.py
+++ b/discord/errors.py
@@ -62,13 +62,17 @@ class HTTPException(DiscordException):
def __init__(self, response, message):
self.response = response
- self.text = message
+ if type(message) is dict:
+ self.text = message.get('message', '')
+ self.code = message.get('code', 0)
+ else:
+ self.text = message
fmt = '{0.reason} (status code: {0.status})'
- if len(message) < 100:
+ if len(self.text):
fmt = fmt + ': {1}'
- super().__init__(fmt.format(self.response, message))
+ super().__init__(fmt.format(self.response, self.text))
class Forbidden(HTTPException):
"""Exception that's thrown for when status code 403 occurs.