Better behavior for failed connections in brew search
Fixes Homebrew/homebrew#20868.
This commit is contained in:
parent
621c44dbd2
commit
59fdcfd4d0
@ -33,7 +33,11 @@ module Homebrew extend self
|
|||||||
|
|
||||||
if count == 0 and not blacklisted? query
|
if count == 0 and not blacklisted? query
|
||||||
puts "No formula found for #{query.inspect}. Searching open pull requests..."
|
puts "No formula found for #{query.inspect}. Searching open pull requests..."
|
||||||
|
begin
|
||||||
GitHub.find_pull_requests(rx) { |pull| puts pull }
|
GitHub.find_pull_requests(rx) { |pull| puts pull }
|
||||||
|
rescue GitHub::Error => e
|
||||||
|
opoo e.message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -81,6 +85,8 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
results
|
results
|
||||||
|
rescue GitHub::Error
|
||||||
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_formulae rx
|
def search_formulae rx
|
||||||
|
|||||||
@ -261,6 +261,8 @@ end
|
|||||||
module GitHub extend self
|
module GitHub extend self
|
||||||
ISSUES_URI = URI.parse("https://api.github.com/legacy/issues/search/mxcl/homebrew/open/")
|
ISSUES_URI = URI.parse("https://api.github.com/legacy/issues/search/mxcl/homebrew/open/")
|
||||||
|
|
||||||
|
Error = Class.new(StandardError)
|
||||||
|
|
||||||
def open url, headers={}, &block
|
def open url, headers={}, &block
|
||||||
default_headers = {'User-Agent' => HOMEBREW_USER_AGENT}
|
default_headers = {'User-Agent' => HOMEBREW_USER_AGENT}
|
||||||
default_headers['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN
|
default_headers['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN
|
||||||
@ -271,6 +273,8 @@ module GitHub extend self
|
|||||||
else
|
else
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
rescue SocketError => e
|
||||||
|
raise Error, "Failed to connect to: #{url}\n#{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_issue_matching(query, &block)
|
def each_issue_matching(query, &block)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user