1
0
Fork 0
mirror of synced 2024-06-18 18:44:33 +12:00

Added an error check for an issue where e621 provides data that is not json encodable

This commit is contained in:
phxntxm 2016-10-01 13:12:17 -05:00
parent a51ef0879a
commit a3d1c7ea63

View file

@ -7,6 +7,7 @@ import aiohttp
import random
import re
import math
import json
class Links:
@ -142,9 +143,12 @@ class Links:
url += "%20rating:explicit"
else:
url += "%20rating:safe"
async with self.session.get(url, headers=self.headers) as r:
data = await r.json()
try:
async with self.session.get(url, headers=self.headers) as r:
data = await r.json()
except json.JSONDecodeError:
await self.bot.say("Sorry, I had trouble connecting at the moment; please try again later")
return
# Try to find an image from the list. If there were no results, we're going to attempt to find
# A number between (0,-1) and receive an error.