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: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?

···

--
Posted via http://www.ruby-forum.com/.

drop the .initialize() would be my first guess

···

On Thu, Nov 7, 2013 at 12:48 PM, Ricardo M. <lists@ruby-forum.com> wrote:

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?

--
Posted via http://www.ruby-forum.com/\.

I dropped it. Got the same error.

···

--
Posted via http://www.ruby-forum.com/.