Appease the dog overlords

This commit is contained in:
Andreas Nedbal 2022-12-27 22:41:07 +01:00 committed by Andreas Nedbal
parent 37f4b78f66
commit 44e144cecc
1 changed files with 6 additions and 4 deletions

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ShareWorker
include Sidekiq::Worker
@ -14,19 +16,19 @@ class ShareWorker
rescue ActiveRecord::RecordNotFound
logger.info "Tried to post answer ##{answer_id} for user ##{user_id} to #{service.titleize} but the user/answer/service did not exist (likely deleted), will not retry."
# The question to be posted was deleted
return
nil
rescue Twitter::Error::DuplicateStatus
logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the status was already posted."
return
nil
rescue Twitter::Error::Forbidden
# User's Twitter account is suspended
logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the account is suspended."
return
nil
rescue Twitter::Error::Unauthorized
# User's Twitter token has expired or been revoked
# TODO: Notify user if this happens (https://github.com/Retrospring/retrospring/issues/123)
logger.info "Tried to post answer ##{answer_id} from user ##{user_id} to Twitter but the token has exired or been revoked."
return
nil
rescue => e
logger.info "failed to post answer #{answer_id} to #{service} for user #{user_id}: #{e.message}"
Sentry.capture_exception(e)