Created
October 4, 2011 11:17
-
-
Save jnstq/1261392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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