From 9f11190f0b525bfcf4a8349ace41d9b28377bc75 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sat, 23 Jun 2012 21:56:16 -0700 Subject: [PATCH] randomreddit: handle invalid json response --- modules/randomreddit.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/randomreddit.py b/modules/randomreddit.py index 385cb1e..d477620 100644 --- a/modules/randomreddit.py +++ b/modules/randomreddit.py @@ -35,8 +35,11 @@ def randomreddit(phenny, input): except: raise GrumbleError('Reddit or subreddit unreachable.') - reddit = json.loads(resp) - post = choice(reddit['data']['children']) + try: + reddit = json.loads(resp) + post = choice(reddit['data']['children']) + except: + raise GrumbleError('Error parsing response from Reddit.') nsfw = False if post['data']['over_18']: