Method: ChefApply::UI::ErrorPrinter.capture_multiple_failures

Defined in:
lib/chef_apply/ui/error_printer.rb

.capture_multiple_failures(e) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/chef_apply/ui/error_printer.rb', line 51

def self.capture_multiple_failures(e)
  out_file = ChefApply::Config.error_output_path
  e.params << out_file # Tell the operator where to find this info
  File.open(out_file, "w") do |out|
    e.jobs.each do |j|
      wrapped = ChefApply::Errors::StandardErrorResolver.wrap_exception(j.exception, j.target_host)
      ep = ErrorPrinter.new(wrapped)
      msg = ep.format_body.tr("\n", " ").gsub(/ {2,}/, " ").chomp.strip
      out.write("Host: #{j.target_host.hostname} ")
      if ep.exception.respond_to? :id
        out.write("Error: #{ep.exception.id}: ")
      else
        out.write(": ")
      end
      out.write("#{msg}\n")
    end
  end
end