Skip to content

Commit

Permalink
wrap whole worker in begin block
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Oct 19, 2016
1 parent 98c7e3a commit 54219a8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/workers/github_issue_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ class GithubIssueWorker
sidekiq_options queue: :low, unique: :until_executed

def perform(name_with_owner, issue_number, token = nil)
token = token || AuthToken.token
repo = GithubRepository.create_from_github(name_with_owner, token)
return unless repo
issue_hash = AuthToken.fallback_client(token).issue(repo.full_name, issue_number)
GithubIssue.create_from_hash(repo, issue_hash)
rescue Octokit::NotFound
nil
begin
token = token || AuthToken.token
repo = GithubRepository.create_from_github(name_with_owner, token)
return unless repo
issue_hash = AuthToken.fallback_client(token).issue(repo.full_name, issue_number)
GithubIssue.create_from_hash(repo, issue_hash)
rescue Octokit::NotFound
nil
end
end
end

0 comments on commit 54219a8

Please sign in to comment.