module WolfCore::FileUtils

def safe_require(missing_files)

def safe_require(missing_files)
  error_counter = {}
  while missing_files.any?
    files_to_require = missing_files
    missing_files = []
    files_to_require.each do |file|
      begin
        # log_object "Requiring file: #{file}"
        require_relative file
      rescue NameError => e
        error_counter[file] = error_counter[file].to_i + 1
        if error_counter[file] >= 10
          log_object "Error requiring file: #{file}"
          log_object e, title: 'Error is'
        end
        missing_files << file if error_counter[file] < 15
      end
    end
  end
end