From daf26dce1332acbe73668945ef87c47202f8cc45 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Thu, 31 Aug 2017 18:01:16 +0000 Subject: [PATCH] Added some error handling --- main.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 93905bb..8ef6697 100644 --- a/main.py +++ b/main.py @@ -21,9 +21,17 @@ for comment in rall.stream.comments(): print(match.group(),'\n',needed.title(),'\n') # Reply to the comment - #response = comment.reply( "I'll look for someone who", ' '.join(match.group(1,5)).lower() ) - #print("Replied to comment "+comment.id+":",response.permalink()) + #try: + # response = comment.reply( "I'll look for someone who", ' '.join(match.group(1,5)).lower() ) + #except: + # print("Failed to reply to comment"+comment.id); raise + #else: + # print("Replied to comment "+comment.id+":",response.permalink()) # Post to our sub - post = sub.submit(needed.title(), url='https://www.reddit.com'+comment.permalink(), resubmit=False) - print("Posted to sub:",post.shortlink) + try: + post = sub.submit(needed.title(), url='https://www.reddit.com'+comment.permalink(), resubmit=False) + except: + print("Failed to post to our sub"); raise + else: + print("Posted to sub:",post.shortlink)