aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2012-03-16 11:55:30 +0000
committerMax Howell2012-03-16 21:06:17 +0000
commit3d5b4af523dca55fe7fa49433eec2519254b060b (patch)
treec987595d91338b69c98366861d3831a244e8f1eb /Library
parent15f3e9ea771c80dd4af2af8840a3609adc873fd3 (diff)
downloadbrew-3d5b4af523dca55fe7fa49433eec2519254b060b.tar.bz2
Tell the user to tap (if req.) for tapped deps
Also propagate dependency info through exception if possible so the error message is more useful.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/exceptions.rb16
-rw-r--r--Library/Homebrew/formula_installer.rb6
2 files changed, 21 insertions, 1 deletions
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index 0d55336d1..f577ecae5 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -24,10 +24,24 @@ end
class FormulaUnavailableError < RuntimeError
attr :name
+ attr :dependent, true
+
+ def dependent_s
+ "(dependency of #{dependent})" if dependent and dependent != name
+ end
+
+ def to_s
+ if name =~ %r{(\w+)/(\w+)/(\w+)} then <<-EOS.undent
+ No available formula for #$3 #{dependent_s}
+ Please tap it and then try again: brew tap #$1/#$2
+ EOS
+ else
+ "No available formula for #{name} #{dependent_s}"
+ end
+ end
def initialize name
@name = name
- super "No available formula for #{name}"
end
end
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 96dae5bac..76618ad0c 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -44,6 +44,12 @@ class FormulaInstaller
raise CannotInstallFormulaError, "You must `brew link #{dep}' before #{f} can be installed"
end
end unless ignore_deps
+
+ rescue FormulaUnavailableError => e
+ # this is sometimes wrong if the dependency chain is more than one deep
+ # but can't easily fix this without a rewrite FIXME-brew2
+ e.dependent = f.name
+ raise
end
def install