Exception: Nanoc::Core::Errors::DependencyCycle

Inherits:
Nanoc::Core::Error show all
Defined in:
lib/nanoc/core/errors.rb

Overview

Error that is raised during site compilation when an item (directly or indirectly) includes its own item content, leading to endless recursion.

Instance Method Summary collapse

Constructor Details

#initialize(stack) ⇒ DependencyCycle

Returns a new instance of DependencyCycle.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/nanoc/core/errors.rb', line 75

def initialize(stack)
  start_idx = stack.index(stack.last)
  cycle = stack[start_idx..-2]

  msg_bits = []
  msg_bits << 'The site cannot be compiled because there is a dependency cycle:'
  msg_bits << ''
  cycle.each.with_index do |r, i|
    msg_bits << "    (#{i + 1}) item #{r.item.identifier}, rep #{r.name.inspect}, uses compiled content of"
  end
  msg_bits << msg_bits.pop + ' (1)'

  super(msg_bits.map { |x| x + "\n" }.join(''))
end