I am trying to store a block with retry statement, but am getting a syntax error: Invalid retry. How do I store it right?
retries = 3
proc = Proc.new do
if retries > 0
p " Retries left: #{retries}"
retries -= 1
retry
end
end
begin
...
rescue SomeErrorOne
proc.call
rescue SomeErrorTwo
proc.call
end
Try to change the retry to redo. I think some changes were made in Ruby 1.9 as the retry keyword was abused.
The difference can be found here: http://rubyquicktips.com/post/1122838559/redo-vs-retry See the comment at the bottom.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With