Catching timeout errors with ruby mechanize
问题 I have a mechanize function to log me out of a site but on very rare occasions it times me out. The function involves going to a specific page, and then clicking on a logout button. On the occasional that mechanize suffers a timeout when either going to the logout page or clicking the logout button the code crashes. So I put in a small rescue and it seems to be working as seen below the first piece of code. def logmeout(agent) page = agent.get('http://www.example.com/') agent.click(page.link