Can't rescue this (http-access2)

H

Horacio Sanson

I have a code like this

def connect(redirect=3)

# Do we have a url to process do we?? if not simply return
if not @uri
return nil
end

begin
@clnt = HTTPAccess2::Client.new()
@clnt.set_cookie_store("cookie.dat")
@resp = @clnt.get(@uri)
@code = @resp.status.to_s
@message = @resp.reason
rescue SocketError
@code = "404"
@message = "Not Found"
rescue Exception => e
puts "#{self.class} Exception connecting to #{@uri.to_s} : #{e.to_s}"
@code = "408"
@message = e.to_s
end

@resp
end



this works as expected but some times (not always) I get an error and the
scripts bails out.

c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1466:in `gets': Invalid
argument (Errno::EINVAL)
from c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1466:in
`parse_header'
from c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1464:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1464:in
`parse_header'
from c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1422:in
`read_header'
from c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1254:in
`get_status'
from c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:466:in
`do_get_header'
from c:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:436:in
`do_get_block'
... 6 levels...
from ./scrapper.rb:1000:in `start'
from ./scrapper.rb:984:in `each'
from ./scrapper.rb:984:in `start'
from main.rb:208



I think I am rescuing all possible things that could go wrong here so my
script should continue ignoring this error but the scripts stops.

How can I rescue this??

regards
Horacio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top