mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 12:29:30 +02:00
Handle JSON decode error
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import json
|
||||
|
||||
|
||||
class HttpException(Exception):
|
||||
"""Base Exception class representing a HTTP exception."""
|
||||
|
||||
@@ -24,11 +27,16 @@ class RateLimited(HttpException):
|
||||
|
||||
def __init__(self, response):
|
||||
self.response = response
|
||||
try:
|
||||
self.json = self.response.json()
|
||||
except json.JSONDecodeError:
|
||||
self.json = dict()
|
||||
self.message = self.response.text
|
||||
else:
|
||||
self.message = self.json["message"]
|
||||
self.is_global = self.json["global"]
|
||||
self.retry_after = self.json["retry_after"]
|
||||
super().__init__(self.json["message"])
|
||||
super().__init__(self.message)
|
||||
|
||||
|
||||
class Unauthorized(HttpException):
|
||||
|
||||
Reference in New Issue
Block a user