aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMasayuki Morita2017-01-03 14:36:08 +0900
committerMasayuki Morita2017-01-03 14:36:08 +0900
commit248beb9bf6ce0b9afc97dfc72067b6acfcb5eeb8 (patch)
tree2692cd03471cc8b13bca5bfc3e2f501aaf02100b /Library/Homebrew
parentb9cc52db455b879fa048421851d7bd43bddde817 (diff)
downloadbrew-248beb9bf6ce0b9afc97dfc72067b6acfcb5eeb8.tar.bz2
Move error messages in GitHubReleaseDownloadStrategy to raise argument
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/download_strategy.rb18
1 files changed, 4 insertions, 14 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index fa54ef716..6e618f720 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -546,16 +546,10 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy
super
@github_token = ENV["GITHUB_TOKEN"]
- unless @github_token
- puts "Environmental variable GITHUB_TOKEN is required."
- raise CurlDownloadStrategyError, @url
- end
+ raise CurlDownloadStrategyError, "Environmental variable GITHUB_TOKEN is required." unless @github_token
url_pattern = %r|https://github.com/(\S+)/(\S+)/releases/download/(\S+)/(\S+)|
- unless @url =~ url_pattern
- puts "Invalid url pattern for GitHub Release."
- raise CurlDownloadStrategyError, @url
- end
+ raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release." unless @url =~ url_pattern
_, @owner, @repo, @tag, @filename = *(@url.match(url_pattern))
end
@@ -580,10 +574,7 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy
def resolve_asset_id
release_metadata = fetch_release_metadata
assets = release_metadata["assets"].select{ |a| a["name"] == @filename }
- if assets.empty?
- puts "Asset file not found."
- raise CurlDownloadStrategyError, @url
- end
+ raise CurlDownloadStrategyError, "Asset file not found." if assets.empty?
return assets.first["id"]
end
@@ -597,8 +588,7 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy
release_response = open(release_url, {:http_basic_authentication => [@github_token]}).read
rescue OpenURI::HTTPError => e
if e.message == '404 Not Found'
- puts "GitHub Release not found."
- raise CurlDownloadStrategyError, @url
+ raise CurlDownloadStrategyError, "GitHub Release not found."
else
raise e
end