Skip to content

Instantly share code, notes, and snippets.

@jnunemaker jnunemaker/gist:78253 forked from carlo/gist:58145
Created Mar 12, 2009

Embed
What would you like to do?
# more examples here: http://blog.codefront.net/2008/01/14/retrying-code-blocks-in-ruby-on-exceptions-whatever/
begin
retryable( :tries => 2 ) do
Timeout::timeout(5) do |t|
xml_string = open( my_url, "User-Agent" => "Firefox/2.0" ).read
end
end
rescue Timeout::Error
LOG.error("Timeout error: #{$!} (#{my_url})")
rescue OpenURI::HTTPError
LOG.error("HTTP error: #{$!} (#{my_url})")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.