HTTParty gem如何解决错误

时间:2014-03-13 09:17:04

标签: ruby-on-rails ruby httparty

我想使用httparty gem来解决与所有连接错误相关的错误(通过peer,timeout等重置..)

类似的东西:

  begin
  response = HTTParty.get('http://somewhere.url', http_proxyaddr: proxy_addr,http_proxyport: proxy_port, timeout: 10)
  rescue HTTParty::Error => e
    puts 'HttParty::Error '+ e.message
    retry        
  rescue StandardError => e
   puts 'StandardError '+ e.message
  end

0 个答案:

没有答案