diff options
| author | Jack Nagel | 2014-06-24 20:59:26 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-06-24 21:01:04 -0500 | 
| commit | 32b9e5bc0c4b9d1b83942556d49dc3338edec504 (patch) | |
| tree | c1c9f4e737c463a25ceede54e53f21e6fc76d1db /Library/Homebrew/utils.rb | |
| parent | b365ee31847945204aef6f91d86dc0df8c24dfc0 (diff) | |
| download | homebrew-32b9e5bc0c4b9d1b83942556d49dc3338edec504.tar.bz2 | |
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. #30407.
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 19 | 
1 files changed, 11 insertions, 8 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index ab186eedd..6684b3696 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -311,15 +311,18 @@ module GitHub extend self      }      default_headers['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN -    Kernel.open(url, default_headers.merge(headers)) do |f| -      yield Utils::JSON.load(f.read) + +    begin +      Kernel.open(url, default_headers.merge(headers)) do |f| +        yield Utils::JSON.load(f.read) +      end +    rescue OpenURI::HTTPError => e +      handle_api_error(e) +    rescue SocketError, OpenSSL::SSL::SSLError => e +      raise Error, "Failed to connect to: #{url}\n#{e.message}", e.backtrace +    rescue Utils::JSON::Error => e +      raise Error, "Failed to parse JSON response\n#{e.message}", e.backtrace      end -  rescue OpenURI::HTTPError => e -    handle_api_error(e) -  rescue SocketError, OpenSSL::SSL::SSLError => e -    raise Error, "Failed to connect to: #{url}\n#{e.message}", e.backtrace -  rescue Utils::JSON::Error => e -    raise Error, "Failed to parse JSON response\n#{e.message}", e.backtrace    end    def handle_api_error(e)  | 
