From 630b8cee88a5f01d79999380dad4fc4e48a09601 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Tue, 10 Oct 2017 21:42:29 +0200 Subject: [PATCH] OctoFetcher: extract method fail_with_message (#569) --- lib/github_changelog_generator/octo_fetcher.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/github_changelog_generator/octo_fetcher.rb b/lib/github_changelog_generator/octo_fetcher.rb index 2575a91..8eb2eae 100644 --- a/lib/github_changelog_generator/octo_fetcher.rb +++ b/lib/github_changelog_generator/octo_fetcher.rb @@ -311,14 +311,17 @@ Make sure, that you push tags to remote repo via 'git push --tags'" yield end rescue MovedPermanentlyError => e - Helper.log.error("#{e.class}: #{e.message}") - sys_abort("The repository has moved, please update your configuration") + fail_with_message(e, "The repository has moved, update your configuration") rescue Octokit::Forbidden => e - Helper.log.error("#{e.class}: #{e.message}") - sys_abort("Exceeded retry limit") + fail_with_message(e, "Exceeded retry limit") rescue Octokit::Unauthorized => e + fail_with_message(e, "Error: wrong GitHub token") + end + + # Presents the exception, and the aborts with the message. + def fail_with_message(e, message) Helper.log.error("#{e.class}: #{e.message}") - sys_abort("Error: wrong GitHub token") + sys_abort(message) end # Exponential backoff