Make HTTPException get the error JSON's message attribute.

This commit is contained in:
Rapptz 2016-06-12 20:36:07 -04:00
parent 1fba1b06fa
commit e8c32c542e

View File

@ -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.