aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/download_strategy.rb8
-rw-r--r--Library/Homebrew/exceptions.rb16
-rw-r--r--Library/Homebrew/formula.rb4
-rw-r--r--Library/Homebrew/utils.rb6
4 files changed, 16 insertions, 18 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index d043ef450..f63ed98a3 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -55,9 +55,13 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
unless @tarball_path.exist?
begin
_fetch
- rescue Exception
+ rescue Exception => e
ignore_interrupts { @tarball_path.unlink if @tarball_path.exist? }
- raise
+ if e.kind_of? ErrorDuringExecution
+ raise CurlDownloadStrategyError, "Download failed: #{@url}"
+ else
+ raise
+ end
end
else
puts "File already downloaded in #{File.dirname(@tarball_path)}"
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index e77c0573a..cd5103963 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -113,16 +113,10 @@ class BuildError < Homebrew::InstallationError
end
end
-class DownloadError < RuntimeError
- attr :command
- attr :args
- attr :exit_status
+# raised in CurlDownloadStrategy.fetch
+class CurlDownloadStrategyError < RuntimeError
+end
- def initialize cmd, args, status
- @command = cmd
- @args = args
- args.map!{ |arg| arg.to_s.gsub " ", "\\ " }
- super "#{cmd} #{args.join ' '}\nDownloader failed with exit status #{status}"
- @exit_status = status
- end
+# raised by safe_system in utils.rb
+class ErrorDuringExecution < RuntimeError
end
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 6ed03af14..f8d86844f 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -561,9 +561,9 @@ private
begin
fetched = downloader.fetch
- rescue DownloadError => e
+ rescue CurlDownloadStrategyError => e
raise e if mirror_list.empty?
- opoo "#{e.message}\nTrying a mirror."
+ puts "Trying a mirror..."
url, specs = mirror_list.shift.values_at :url, :specs
downloader = download_strategy.new url, name, version, specs
retry
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 485995615..dc7bf5d42 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -92,7 +92,7 @@ end
def safe_system cmd, *args
unless Homebrew.system cmd, *args
args = args.map{ |arg| arg.to_s.gsub " ", "\\ " } * " "
- raise "Failure while executing: #{cmd} #{args}"
+ raise ErrorDuringExecution, "Failure while executing: #{cmd} #{args}"
end
end
@@ -106,13 +106,13 @@ end
def curl *args
curl = Pathname.new '/usr/bin/curl'
- raise "#{curl} is not an executable!" unless curl.exist? and curl.executable?
+ raise "#{curl} is not 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
- raise DownloadError.new curl, args, $? unless Homebrew.system curl, *args
+ safe_system curl, *args
end
def puts_columns items, star_items=[]