Skip to content

Commit

Permalink
Retry only on Yt::ConnectionError
Browse files Browse the repository at this point in the history
  • Loading branch information
treble37 committed Jun 28, 2017
1 parent 2d5a8e5 commit 946e731
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/yt/http_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@ def run
parse_response!
end
else
retry_run
raise Yt::HTTPError, error_message
end
rescue Yt::ConnectionError
retry_run
end

private

# retry the run method in case of a random 500 error from YouTube API
def retry_run
if @retried
raise Yt::HTTPError, error_message
raise Yt::ConnectionError, error_message
else
@retried = true
@response = nil
Expand Down

0 comments on commit 946e731

Please sign in to comment.