Skip to content

Commit

Permalink
randomreddit: handle invalid json response
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantmonkey committed Jun 24, 2012
1 parent 6ecbe4c commit 9f11190
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/randomreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down

0 comments on commit 9f11190

Please sign in to comment.