aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorCharlie Sharpsteen2011-09-14 12:18:35 -0700
committerCharlie Sharpsteen2011-09-19 09:21:36 -0700
commit3b5869acb59c9cc7c9ab0dfdf3fe756f3245511c (patch)
treea927d1dad3f2fee661c9354710563595f650cb93 /Library/Homebrew/utils.rb
parent9332ca98df235cf3b375ee490065947f19c6a3c8 (diff)
downloadhomebrew-3b5869acb59c9cc7c9ab0dfdf3fe756f3245511c.tar.bz2
exceptions.rb: Add DownloadError
`DownloadError` is an exception that download stratigies can throw to indicate that a fetch was incomplete due to a failure in communication. The `curl` method in `utils.rb` has been upgraded to throw a `DownloadError` if something bad happens to `curl` execution.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 5ce54e6fc..485995615 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -1,4 +1,5 @@
require 'pathname'
+require 'exceptions'
class Tty
class <<self
@@ -104,10 +105,14 @@ def quiet_system cmd, *args
end
def curl *args
+ curl = Pathname.new '/usr/bin/curl'
+ raise "#{curl} is not an executable!" unless curl.exist? and curl.executable?
+
+ args = [HOMEBREW_CURL_ARGS, HOMEBREW_USER_AGENT, *args]
# See https://github.com/mxcl/homebrew/issues/6103
args << "--insecure" if MacOS.version < 10.6
- safe_system '/usr/bin/curl', HOMEBREW_CURL_ARGS, HOMEBREW_USER_AGENT, *args unless args.empty?
+ raise DownloadError.new curl, args, $? unless Homebrew.system curl, *args
end
def puts_columns items, star_items=[]