Skip to content

Instantly share code, notes, and snippets.

@baya
Created November 10, 2010 09:10
Show Gist options
  • Save baya/670581 to your computer and use it in GitHub Desktop.
Save baya/670581 to your computer and use it in GitHub Desktop.
help method for visting a url
module Rubber
def self.try(diftimes = [3, 8, 2], options = { }, &block)
val = timeout(diftimes.shift) do
block.call
end
rescue options[:on] || Exception => e
Rails.logger.info("#{Time.now}:#{__FILE__}:#{__LINE__}}:#{e.backtrace.join("\n")}")
retry if diftimes.first
return ""
else
val
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment