def retry_times(n, func) n=n-1 return func.call() rescue => e puts "n=#{n} exception #{e}" if n>0 then retry end end