From e7051c965ebbd7e6b71359ba6bb0a041e9d4bb23 Mon Sep 17 00:00:00 2001 From: Davide Vacca Date: Wed, 21 Oct 2026 10:43:44 +0200 Subject: [PATCH] Raise last error when http code retry helper exhausts retries The helper previously returned an unset/null value after all retries failed, hiding the real API error. It now surfaces the last exception. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- spec/spec_helper.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d2dc7f9..e26f1fc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -112,16 +112,15 @@ def repeat_request_until_http_code_changes(max_retries = 15, # interval --> how many seconds to wait until the next retry # proc --> code containing the request - iteration = 0 - while iteration <= max_retries + last_error = nil + (max_retries + 1).times do begin - instance = proc.call - break - rescue Onfido::ApiError + return proc.call + rescue Onfido::ApiError => e + last_error = e sleep(interval) - iteration += 1 end end - instance + raise last_error end