I use this method to retry my requests if there are retrieval problems.
def with_retries(num_retries = 4)
begin
yield
rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EHOSTUNREACH,
Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error,
WWW::Mechanize::ResponseCodeError
num_retries -= 1
retry unless num_retries < 0
raise
end
end
So I can try three times to get a page:
with_retries(2){page.click()}
before the outer method raises an exception. But I''m not really sure
if I''m
catching all the right exceptions. Anyone know?
-- Zach.