def write_verbose_error(error, stream)
stream.puts "Crashlog created at #{Time.now}"
stream.puts
stream.puts '=== MESSAGE:'
stream.puts
stream.puts "#{error.class}: #{error.message}"
resolution = self.resolution_for(error)
stream.puts "#{resolution}" if resolution
stream.puts
stream.puts '=== COMPILATION STACK:'
stream.puts
if self.stack.empty?
stream.puts " (empty)"
else
self.stack.reverse.each do |obj|
if obj.is_a?(Nanoc::ItemRep)
stream.puts " - [item] #{obj.item.identifier} (rep #{obj.name})"
else
stream.puts " - [layout] #{obj.identifier}"
end
end
end
stream.puts
stream.puts '=== BACKTRACE:'
stream.puts
stream.puts error.backtrace.to_enum(:each_with_index).map { |item, index| " #{index}. #{item}" }.join("\n")
stream.puts
stream.puts '=== VERSION INFORMATION:'
stream.puts
stream.puts Nanoc.version_information
stream.puts
begin
uname = `uname -a`
stream.puts '=== SYSTEM INFORMATION:'
stream.puts
stream.puts uname
stream.puts
rescue Errno::ENOENT
end
stream.puts '=== INSTALLED GEMS:'
stream.puts
self.gems_and_versions.each do |g|
stream.puts " #{g.first} #{g.last.join(', ')}"
end
stream.puts
stream.puts '=== ENVIRONMENT:'
stream.puts
ENV.sort.each do |e|
stream.puts "#{e.first} => #{e.last.inspect}"
end
stream.puts
if File.exist?('Gemfile.lock')
stream.puts '=== GEMFILE.LOCK:'
stream.puts
stream.puts File.read('Gemfile.lock')
stream.puts
end
stream.puts '=== $LOAD_PATH:'
stream.puts
$LOAD_PATH.each_with_index do |i, index|
stream.puts " #{index}. #{i}"
end
end