Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Tell the user to tap (if req.) for tapped deps
Browse files Browse the repository at this point in the history
Also propagate dependency info through exception if possible so the error message is more useful.
  • Loading branch information
mxcl committed Mar 16, 2012
1 parent 0364fef commit b52085b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Library/Homebrew/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,24 @@ def initialize name

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

Expand Down
6 changes: 6 additions & 0 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def check_install_sanity
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
Expand Down

0 comments on commit b52085b

Please sign in to comment.