Forum: Ruby Mechanize ResponseCodeError

D78922567581da4f6536d1e1aa5fb67e?d=identicon&s=25 Ricardo M. (ricardo_m55)
on 2013-11-07 18:48
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:in
`response_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:in
`post_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:in
`submit'
  from pruebatron.txt:26:in `<main>'

Any ideas?
23172b6630dc631a134c9bad2fec2a39?d=identicon&s=25 Chris Hulan (Guest)
on 2013-11-07 20:14
(Received via mailing list)
drop the .initialize() would be my first guess
D78922567581da4f6536d1e1aa5fb67e?d=identicon&s=25 Ricardo M. (ricardo_m55)
on 2013-11-07 20:59
I dropped it. Got the same error.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.