Mechanize ResponseCodeError

I’m having trouble handling the ResponseCodeError in Mechanize.

Right now I have in my script:

begin
puts “Sesion iniciada”
agent.page.link_with(:href => ‘/logout’).click

rescue Mechanize::ResponseCodeError.initialize()
puts “An error occurred”

end

But the error is not being handled. I’ve also tried handling
Net::HTTPInternalServerError, since that is what I see in the bactrace
but that didn’t work either.

here’s the backtrace:

/home/ricardo/.rvm/gems/ruby-1.9.3-p448/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:306:in
fetch': 500 => Net::HTTPInternalServerError for http://thesite.info/ -- unhandled response (Mechanize::ResponseCodeError) from /home/ricardo/.rvm/gems/ruby-1.9.3-p448/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:974:inresponse_redirect’
from
/home/ricardo/.rvm/gems/ruby-1.9.3-p448/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:298:in
fetch' from /home/ricardo/.rvm/gems/ruby-1.9.3-p448/gems/mechanize-2.7.2/lib/mechanize.rb:1273:inpost_form’
from
/home/ricardo/.rvm/gems/ruby-1.9.3-p448/gems/mechanize-2.7.2/lib/mechanize.rb:540:in
submit' from /home/ricardo/.rvm/gems/ruby-1.9.3-p448/gems/mechanize-2.7.2/lib/mechanize/form.rb:223:insubmit’
from pruebatron.txt:26:in `’

Any ideas?

drop the .initialize() would be my first guess

I dropped it. Got the same error.