lib/eco/api/session/batch.rb in eco-helpers-2.0.18 vs lib/eco/api/session/batch.rb in eco-helpers-2.0.19
- old
+ new
@@ -134,14 +134,16 @@
def offer_retry_on(error_type, retries_left = 3, &block)
begin
block.call
rescue error_type => e
raise unless retries_left > 0
- print "Batch TimeOut. You have #{retries_left} retries left. Do you want to retry (y/N)? "
- if (res = STDIN.gets.chomp) && res[0].downcase == "y"
- offer_retry_on(error_type, retries_left - 1, &block)
- else
- raise
+ explanation = "Batch TimeOut. You have #{retries_left} retries left."
+ prompt_user("Do you want to retry (y/N)?", explanation, default: "Y", timeout: 10) do |response|
+ if response.upcase.start_with?("Y")
+ offer_retry_on(error_type, retries_left - 1, &block)
+ else
+ raise
+ end
end
end
end
def str_stats(start, count)