lib/nanoc/base/errors.rb in nanoc-4.7.0 vs lib/nanoc/base/errors.rb in nanoc-4.7.1

- old
+ new

@@ -66,15 +66,20 @@ end end # Error that is raised during site compilation when an item (directly or # indirectly) includes its own item content, leading to endless recursion. - class RecursiveCompilation < Generic - # @param [Array<Nanoc::Int::ItemRep>] reps A list of item representations - # that mutually depend on each other - def initialize(reps) - list = reps.map(&:inspect).join("\n") - super("The site cannot be compiled because the following items mutually depend on each other:\n#{list}.") + class DependencyCycle < Generic + def initialize(graph) + cycle = graph.any_cycle + + msg_bits = [] + msg_bits << 'The site cannot be compiled because there is a dependency cycle:' + msg_bits << '' + cycle.each.with_index { |r, i| msg_bits << " (#{i + 1}) item #{r.item.identifier}, rep #{r.name.inspect}, depends on" } + msg_bits.last << ' (1)' + + super(msg_bits.map { |x| x + "\n" }.join('')) end end # Error that is raised when no rules file can be found in the current # working directory.