aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils/github.rb
diff options
context:
space:
mode:
authorMike McQuaid2016-07-12 19:46:29 +0100
committerGitHub2016-07-12 19:46:29 +0100
commit23306ab434afc185e22a0f357a27e8da687620af (patch)
treedcf29ed5354a34f609b1250d6f7c4ea81c5cbf12 /Library/Homebrew/utils/github.rb
parented1d1e51da6bf464d6e461f5214e49f17b1f1842 (diff)
downloadbrew-23306ab434afc185e22a0f357a27e8da687620af.tar.bz2
github: produce better curl error messages. (#441)
* global: add RUBY_TWO global variable. * test-bot: use RUBY_TWO global variable. * github: produce better curl error messages. If we don't know why curl has failed then ensure that the error messages that it produced are included as part of the user output.
Diffstat (limited to 'Library/Homebrew/utils/github.rb')
-rw-r--r--Library/Homebrew/utils/github.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb
index 36f6257f7..c5dbedd6c 100644
--- a/Library/Homebrew/utils/github.rb
+++ b/Library/Homebrew/utils/github.rb
@@ -146,7 +146,8 @@ module GitHub
args += ["--dump-header", "#{headers_tmpfile.path}"]
- output, _, http_code = curl_output(url.to_s, *args).rpartition("\n")
+ output, errors, status = curl_output(url.to_s, *args)
+ output, _, http_code = output.rpartition("\n")
output, _, http_code = output.rpartition("\n") if http_code == "000"
headers = headers_tmpfile.read
ensure
@@ -159,8 +160,8 @@ module GitHub
end
begin
- if !http_code.start_with?("2") && !$?.success?
- raise_api_error(output, http_code, headers)
+ if !http_code.start_with?("2") && !status.success?
+ raise_api_error(output, errors, http_code, headers)
end
json = Utils::JSON.load output
if block_given?
@@ -173,7 +174,7 @@ module GitHub
end
end
- def raise_api_error(output, http_code, headers)
+ def raise_api_error(output, errors, http_code, headers)
meta = {}
headers.lines.each do |l|
key, _, value = l.delete(":").partition(" ")
@@ -197,7 +198,7 @@ module GitHub
raise HTTPNotFoundError, output
else
error = Utils::JSON.load(output)["message"] rescue nil
- error ||= output
+ error ||= "curl failed! #{errors}"
raise Error, error
end
end