Fix uninitialized constant error in GitHub.open
The error handling depends on side effects of `require "net/https"`, so it should be wrapped in an explicit begin block. cf. Homebrew/homebrew#30407.
This commit is contained in:
parent
3d69e5ab7b
commit
2daabe9863
@ -311,6 +311,8 @@ module GitHub extend self
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
begin
|
||||||
Kernel.open(url, default_headers.merge(headers)) do |f|
|
Kernel.open(url, default_headers.merge(headers)) do |f|
|
||||||
yield Utils::JSON.load(f.read)
|
yield Utils::JSON.load(f.read)
|
||||||
end
|
end
|
||||||
@ -321,6 +323,7 @@ module GitHub extend self
|
|||||||
rescue Utils::JSON::Error => e
|
rescue Utils::JSON::Error => e
|
||||||
raise Error, "Failed to parse JSON response\n#{e.message}", e.backtrace
|
raise Error, "Failed to parse JSON response\n#{e.message}", e.backtrace
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def handle_api_error(e)
|
def handle_api_error(e)
|
||||||
if e.io.meta["x-ratelimit-remaining"].to_i <= 0
|
if e.io.meta["x-ratelimit-remaining"].to_i <= 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user