class ChefConfig::WorkstationConfigLoader
def apply_config(config_content, config_file_path)
def apply_config(config_content, config_file_path) Config.from_string(config_content, config_file_path) rescue SignalException raise rescue SyntaxError => e message = "" message << "You have invalid ruby syntax in your config file #{config_file_path}\n\n" message << "#{e.class.name}: #{e.message}\n" if file_line = e.message[/#{Regexp.escape(config_file_path)}:\d+/] line = file_line[/:(\d+)$/, 1].to_i message << highlight_config_error(config_file_path, line) end raise ChefConfig::ConfigurationError, message rescue Exception => e message = "You have an error in your config file #{config_file_path}\n\n" message << "#{e.class.name}: #{e.message}\n" filtered_trace = e.backtrace.grep(/#{Regexp.escape(config_file_path)}/) filtered_trace.each { |bt_line| message << " " << bt_line << "\n" } unless filtered_trace.empty? line_nr = filtered_trace.first[/#{Regexp.escape(config_file_path)}:(\d+)/, 1] message << highlight_config_error(config_file_path, line_nr.to_i) end raise ChefConfig::ConfigurationError, message end