diff options
| author | Adam Vandenberg | 2009-09-23 10:06:19 -0700 |
|---|---|---|
| committer | Max Howell | 2009-09-25 19:20:59 +0100 |
| commit | b2a857da54e3290ef8601e3f6415f1b945a42736 (patch) | |
| tree | aba56bf45e6c4c1581cb6eef5fdcbd5531855a4d /Library | |
| parent | 1e3dff7b8ed78fb3e2ffcca64282f45362d5dcd1 (diff) | |
| download | brew-b2a857da54e3290ef8601e3f6415f1b945a42736.tar.bz2 | |
Add better error message for misnamed formula class.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index ed65e5426..2c7f10b5a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -30,8 +30,11 @@ class BuildError <ExecutionError end class FormulaUnavailableError <RuntimeError def initialize name + @name = name super "No available formula for #{name}" end + + attr_reader :name end @@ -171,7 +174,17 @@ class Formula else require self.path(name) end - return eval(self.class_s(name)).new(name) + begin + klass_name =self.class_s(name) + klass = eval(klass_name) + rescue NameError + # TODO really this text should be encoded into the exception + # and only shown if the UI deems it correct to show it + onoe "class \"#{klass_name}\" expected but not found in #{name}.rb" + puts "Double-check the name of the class in that formula." + raise LoadError + end + return klass.new(name) rescue LoadError raise FormulaUnavailableError.new(name) end |
