Make HTTPException get the error JSON's message attribute.
This commit is contained in:
		| @@ -62,13 +62,17 @@ class HTTPException(DiscordException): | |||||||
|  |  | ||||||
|     def __init__(self, response, message): |     def __init__(self, response, message): | ||||||
|         self.response = response |         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})' |         fmt = '{0.reason} (status code: {0.status})' | ||||||
|         if len(message) < 100: |         if len(self.text): | ||||||
|             fmt = fmt + ': {1}' |             fmt = fmt + ': {1}' | ||||||
|  |  | ||||||
|         super().__init__(fmt.format(self.response, message)) |         super().__init__(fmt.format(self.response, self.text)) | ||||||
|  |  | ||||||
| class Forbidden(HTTPException): | class Forbidden(HTTPException): | ||||||
|     """Exception that's thrown for when status code 403 occurs. |     """Exception that's thrown for when status code 403 occurs. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user