문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top