aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMartin Afanasjew2016-04-16 20:58:20 +0200
committerMartin Afanasjew2016-04-17 21:16:01 +0200
commitc3076f0b6923f595f3d70eb849eeb8b0b204da3b (patch)
treefa9e84fbed5b6e849d85a4e7a71c0d296013442f /Library
parent1ded40a7441c66fa3127f0129403bf03a7db4561 (diff)
downloadbrew-c3076f0b6923f595f3d70eb849eeb8b0b204da3b.tar.bz2
formulary: use FormulaClassUnavailableError
Present a more helpful error message if a formula file was loaded, but the class(es) therein didn't match the expected formula class name.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formulary.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 79e4c946b..28e79c68f 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -23,8 +23,12 @@ class Formulary
begin
mod.const_get(class_name)
- rescue NameError => e
- raise FormulaUnavailableError, name, e.backtrace
+ rescue NameError => original_exception
+ class_list = mod.constants.
+ map { |const_name| mod.const_get(const_name) }.
+ select { |const| const.is_a?(Class) }
+ e = FormulaClassUnavailableError.new(name, path, class_name, class_list)
+ raise e, "", original_exception.backtrace
end
end