Skip to content

Commit

Permalink
github: Raise specific exception on find pr fails
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Kostiuk <konstantin@daynix.com>
  • Loading branch information
kostyanf14 committed Nov 11, 2024
1 parent 30f7da1 commit aff9829
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/auxiliary/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions lib/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit aff9829

Please sign in to comment.