From 5492c3889e24d4ca2db3f97771362cdec0a91246 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 10 Jan 2016 14:36:51 +0100 Subject: [PATCH] Improved error handling. --- lib/tweet_base.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/tweet_base.rb b/lib/tweet_base.rb index c33f75997..fbbf6df48 100644 --- a/lib/tweet_base.rb +++ b/lib/tweet_base.rb @@ -199,10 +199,16 @@ class TweetBase if existing_article ticket = existing_article.ticket else - parent_tweet = @client.status(tweet.in_reply_to_status_id) - ticket = to_group(parent_tweet, group_id, channel) + begin + parent_tweet = @client.status(tweet.in_reply_to_status_id) + ticket = to_group(parent_tweet, group_id, channel) + rescue Twitter::Error::NotFound + # just ignore if tweet has already gone + Rails.logger.info "Can't import tweet (#{tweet.in_reply_to_status_id}), tweet not found" + end end - else + end + if !ticket ticket = to_ticket(tweet, user, group_id, channel) end to_article(tweet, user, ticket)