Move error messages in GitHubReleaseDownloadStrategy to raise argument
This commit is contained in:
parent
b9cc52db45
commit
248beb9bf6
@ -546,16 +546,10 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy
|
|||||||
super
|
super
|
||||||
|
|
||||||
@github_token = ENV["GITHUB_TOKEN"]
|
@github_token = ENV["GITHUB_TOKEN"]
|
||||||
unless @github_token
|
raise CurlDownloadStrategyError, "Environmental variable GITHUB_TOKEN is required." unless @github_token
|
||||||
puts "Environmental variable GITHUB_TOKEN is required."
|
|
||||||
raise CurlDownloadStrategyError, @url
|
|
||||||
end
|
|
||||||
|
|
||||||
url_pattern = %r|https://github.com/(\S+)/(\S+)/releases/download/(\S+)/(\S+)|
|
url_pattern = %r|https://github.com/(\S+)/(\S+)/releases/download/(\S+)/(\S+)|
|
||||||
unless @url =~ url_pattern
|
raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release." unless @url =~ url_pattern
|
||||||
puts "Invalid url pattern for GitHub Release."
|
|
||||||
raise CurlDownloadStrategyError, @url
|
|
||||||
end
|
|
||||||
|
|
||||||
_, @owner, @repo, @tag, @filename = *(@url.match(url_pattern))
|
_, @owner, @repo, @tag, @filename = *(@url.match(url_pattern))
|
||||||
end
|
end
|
||||||
@ -580,10 +574,7 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy
|
|||||||
def resolve_asset_id
|
def resolve_asset_id
|
||||||
release_metadata = fetch_release_metadata
|
release_metadata = fetch_release_metadata
|
||||||
assets = release_metadata["assets"].select{ |a| a["name"] == @filename }
|
assets = release_metadata["assets"].select{ |a| a["name"] == @filename }
|
||||||
if assets.empty?
|
raise CurlDownloadStrategyError, "Asset file not found." if assets.empty?
|
||||||
puts "Asset file not found."
|
|
||||||
raise CurlDownloadStrategyError, @url
|
|
||||||
end
|
|
||||||
|
|
||||||
return assets.first["id"]
|
return assets.first["id"]
|
||||||
end
|
end
|
||||||
@ -597,8 +588,7 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy
|
|||||||
release_response = open(release_url, {:http_basic_authentication => [@github_token]}).read
|
release_response = open(release_url, {:http_basic_authentication => [@github_token]}).read
|
||||||
rescue OpenURI::HTTPError => e
|
rescue OpenURI::HTTPError => e
|
||||||
if e.message == '404 Not Found'
|
if e.message == '404 Not Found'
|
||||||
puts "GitHub Release not found."
|
raise CurlDownloadStrategyError, "GitHub Release not found."
|
||||||
raise CurlDownloadStrategyError, @url
|
|
||||||
else
|
else
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user