class ChefCLI::Policyfile::DSL
def eval_policyfile(policyfile_string)
def eval_policyfile(policyfile_string) @policyfile_filename = policyfile_filename instance_eval(policyfile_string, policyfile_filename) validate! self rescue SyntaxError => e @errors << "Invalid Ruby syntax in Policyfile '#{policyfile_filename}':\n\n#{e.message}" rescue SignalException, SystemExit # allow signal from kill, ctrl-C, etc. to bubble up: raise rescue Exception => e error_message = "Evaluation of policyfile '#{policyfile_filename}' raised an exception\n" error_message << " Exception: #{e.class.name} \"#{e}\"\n\n" trace = filtered_bt(policyfile_filename, e) error_message << " Relevant Code:\n" error_message << " #{error_context(policyfile_string, policyfile_filename, e)}\n\n" unless trace.empty? error_message << " Backtrace:\n" # TODO: need a way to disable filtering error_message << filtered_bt(policyfile_filename, e).inject("") { |formatted_trace, line| formatted_trace << " #{line}\n" } end @errors << error_message end