Created
April 30, 2014 12:55
-
-
Save libc/001eb4a18e588651c2b6 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/lib/diddy/helpers.rb b/lib/diddy/helpers.rb | |
index 1b78ecb..5def793 100644 | |
--- a/lib/diddy/helpers.rb | |
+++ b/lib/diddy/helpers.rb | |
@@ -16,11 +16,13 @@ module Diddy | |
def try_with_exception(max_times, delay = 1, &block) | |
index = 0 | |
result = false | |
+ exception = nil | |
while !result && index < max_times do | |
begin | |
result = yield | |
- rescue Exception | |
+ rescue Exception => e | |
+ exception ||= e | |
result = false | |
end | |
@@ -28,6 +30,7 @@ module Diddy | |
index += 1 | |
end | |
+ raise exception if result == false && exception | |
result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment