Hey guys, How do you handle HTTP 500 errors with Mechanize? After researching the web I thought something like this would work: begin Mechanize.new.get(url_which_returns_500) rescue Net::HTTPInternalServerError puts "Life is awesome. Let''s move on" end Anyways, the code in the rescue block will never be executed. Can you guys help me out? Kenny
Mechanize::ResponseCodeError will be raised on a 500. It has #code and #page attributes so you can inspect what went wrong, or switch off specific response codes. mechanize.rubyforge.org/Mechanize/ResponseCodeError.html On Aug 2, 2012, at 6:29 PM, Kenny Meyer <kenny at kennymeyer.net> wrote: Hey guys, How do you handle HTTP 500 errors with Mechanize? After researching the web I thought something like this would work: begin Mechanize.new.get(url_which_returns_500) rescue Net::HTTPInternalServerError puts "Life is awesome. Let''s move on" end Anyways, the code in the rescue block will never be executed. Can you guys help me out? Kenny _______________________________________________ Mechanize-users mailing list Mechanize-users at rubyforge.org rubyforge.org/mailman/listinfo/mechanize-users
Thank you, Tim. On Thu, Aug 2, 2012 at 7:31 PM, T. Snowhite <snowhitster at gmail.com> wrote:> Mechanize::ResponseCodeError will be raised on a 500. > > It has #code and #page attributes so you can inspect what went wrong, or > switch off specific response codes. > > mechanize.rubyforge.org/Mechanize/ResponseCodeError.html > > > On Aug 2, 2012, at 6:29 PM, Kenny Meyer <kenny at kennymeyer.net> wrote: > > Hey guys, > > How do you handle HTTP 500 errors with Mechanize? > > After researching the web I thought something like this would work: > > begin > Mechanize.new.get(url_which_returns_500) > rescue Net::HTTPInternalServerError > puts "Life is awesome. Let''s move on" > end > > Anyways, the code in the rescue block will never be executed. > > Can you guys help me out? > > Kenny > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > rubyforge.org/mailman/listinfo/mechanize-users > _______________________________________________ > Mechanize-users mailing list > Mechanize-users at rubyforge.org > rubyforge.org/mailman/listinfo/mechanize-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <rubyforge.org/pipermail/mechanize-users/attachments/20120802/f6e505fc/attachment.html>