You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to force an exception that Retryable would pick up?
I'm trying to retry if HTTParty response.code is not a 200 or 204. I can get it to raise, but that goes to my begin/rescue, and skips out of Retryable's logic.
def httpPost(results, url = @url)
#ensure_cb = Proc.new { |retries| puts "Total Retries: #{retries}" }
exception_cb = Proc.new { |exception| puts "For URL: #{url}\nRetry-rescued error: #{exception.inspect}"}
begin
Retryable.retryable(:exception_cb => exception_cb, tries: 10, sleep: lambda { |n| 4**n }, on: [Errno::ECONNREFUSED, SocketError, Net::ReadTimeout, HTTParty::Error, Timeout::Error, Errno::EPIPE, OpenSSL::SSL::SSLError, EOFError]) do |retries, exception|
response = HTTParty.post(url, body: results.to_json, headers: {'Content-Type' => 'application/json', 'User-Agent' => 'SendGrid 1.0'})
puts "Attempt #{retries} failed with exception: #{exception}" if retries > 0
exception if not [200, 204].include?(response.code) #throw http-code-level error if not a 200 or 204
puts "Total Attempts: #{retries + 1}" if retries > 0
return response
end
rescue StandardError => e
puts "#{Time.now} - httpPost error: #{e.inspect}"
end
end
The text was updated successfully, but these errors were encountered:
Is there a way to force an exception that Retryable would pick up?
I'm trying to retry if HTTParty response.code is not a 200 or 204. I can get it to raise, but that goes to my begin/rescue, and skips out of Retryable's logic.
The text was updated successfully, but these errors were encountered: