From 3b5869acb59c9cc7c9ab0dfdf3fe756f3245511c Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Wed, 14 Sep 2011 12:18:35 -0700 Subject: 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. --- Library/Homebrew/exceptions.rb | 14 ++++++++++++++ Library/Homebrew/utils.rb | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 72c62dcc7..e77c0573a 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -112,3 +112,17 @@ class BuildError < Homebrew::InstallationError @command == './configure' end end + +class DownloadError < RuntimeError + attr :command + attr :args + attr :exit_status + + 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 +end 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 <