aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2010-07-06 11:48:36 -0700
committerAdam Vandenberg2010-07-08 22:41:51 -0700
commit8deec24d872170aaca5c9143db081d4eb9b02eb2 (patch)
treefc6acb4e11c3796eb46416dfaeffd3b9eec9e8c7 /Library/Homebrew/utils.rb
parente028ce602a28fb8acade6c1223674dc2af6b546d (diff)
downloadhomebrew-8deec24d872170aaca5c9143db081d4eb9b02eb2.tar.bz2
Move exceptions from global to utils; remove duplicate defintions
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index b7ec5317f..b766e2fe7 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -1,3 +1,39 @@
+class ExecutionError <RuntimeError
+ attr :exit_status
+ attr :command
+
+ def initialize cmd, args = [], es = nil
+ @command = cmd
+ super "Failure while executing: #{cmd} #{pretty(args)*' '}"
+ @exit_status = es.exitstatus rescue 1
+ end
+
+ def was_running_configure?
+ @command == './configure'
+ end
+
+ private
+
+ def pretty args
+ args.collect do |arg|
+ if arg.to_s.include? ' '
+ "'#{ arg.gsub "'", "\\'" }'"
+ else
+ arg
+ end
+ end
+ end
+end
+
+class BuildError <ExecutionError
+ attr :env
+
+ def initialize cmd, args = [], es = nil
+ super
+ @env = ENV.to_hash
+ end
+end
+
class Tty
class <<self
def blue; bold 34; end