From aff9829b0c5627ebf3c7b5b0d1fccbb978b8726d Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Mon, 11 Nov 2024 13:42:24 +0200 Subject: [PATCH] github: Raise specific exception on find pr fails Signed-off-by: Kostiantyn Kostiuk --- lib/all.rb | 1 + lib/auxiliary/github.rb | 2 +- lib/exceptions.rb | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/all.rb b/lib/all.rb index 3167ebc0..72e84d18 100644 --- a/lib/all.rb +++ b/lib/all.rb @@ -39,6 +39,7 @@ module AutoHCK autoload_relative :ExtraSoftwareMissingConfig, 'auxiliary/extra_software/exceptions' autoload_relative :Github, 'auxiliary/github' autoload_relative :GithubInitializationError, 'exceptions' + autoload_relative :GithubPullRequestLoadError, 'exceptions' autoload_relative :HCKClient, 'setupmanagers/hckclient' autoload_relative :HCKInstall, 'engines/hckinstall/hckinstall' autoload_relative :HCKStudio, 'setupmanagers/hckstudio' diff --git a/lib/auxiliary/github.rb b/lib/auxiliary/github.rb index f5a3a788..ae422095 100644 --- a/lib/auxiliary/github.rb +++ b/lib/auxiliary/github.rb @@ -132,7 +132,7 @@ def _find_pr(state = nil) Octokit::BadGateway, Octokit::InternalServerError => e @logger.warn("Github server connection error: #{e.message}") # we should fail if can't get updated PR information - raise unless (retries += 1) < GITHUB_API_RETRIES + raise GithubPullRequestLoadError, e unless (retries += 1) < GITHUB_API_RETRIES sleep GITHUB_API_RETRY_SLEEP @logger.info('Trying again execute github.pulls') diff --git a/lib/exceptions.rb b/lib/exceptions.rb index 9f430e6c..74bdd397 100644 --- a/lib/exceptions.rb +++ b/lib/exceptions.rb @@ -14,6 +14,8 @@ class AutoHCKInterrupt < Exception; end # A custom GithubInitializationError error exception class GithubInitializationError < AutoHCKError; end + class GithubPullRequestLoadError < AutoHCKError; end + # A custom Could not open json file exception class OpenJsonError < StandardError; end