Skip to content
Snippets Groups Projects
Commit c3076f0b authored by Martin Afanasjew's avatar Martin Afanasjew
Browse files

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.
parent 1ded40a7
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment