Skip to content

Instantly share code, notes, and snippets.

@jnstq
Created October 4, 2011 11:17
Show Gist options
  • Save jnstq/1261392 to your computer and use it in GitHub Desktop.
Save jnstq/1261392 to your computer and use it in GitHub Desktop.
# excute the given block, retying only when one of the given exceptions is raised
module RetryOnFailure
def retry_on_failure(*exception_list)
retry_count = 5
begin
yield
rescue *exception_list => e
if retry_count > 0
retry_count -= 1
puts "Exception, trying again #{retry_count} more times"
retry
else
HoptoadNotifier.notify(e)
raise e
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment