3

This is my first Ruby app and I'm having problems rescuing errors using Faraday with em_syncrony adapter, my code is like this:

conn = Faraday.new(:url => "http://www.example.com") do |faraday|
  faraday.response :logger
  faraday.adapter  :em_synchrony
end

begin
  html = conn.get do |req|    
    req.options[:timeout] = 1                 
    req.options[:open_timeout] = 1     
  end
rescue
  puts "rescue block"
  return errorTreatment(598)
end

I can't rescue any kind of error, even if I disconnect from internet. I can see the response status is '0' but the code don't raise any errors and don't enter the rescue block.

Another issue is that no matter what value I assign for timeout, it simply won't timeout! I've tried every piece of code about Faraday timeout that I could found with no success.

Any help on this?? Thanks in advance!!

Bruno R.
  • 51
  • 4

0 Answers0