Exception: WCC::Contentful::CircularReferenceError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/wcc/contentful/exceptions.rb

Overview

Raised when an entry contains a circular reference and cannot be represented as a flat tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stack, id) ⇒ CircularReferenceError

Returns a new instance of CircularReferenceError.



17
18
19
20
21
# File 'lib/wcc/contentful/exceptions.rb', line 17

def initialize(stack, id)
  @id = id
  @stack = stack.slice(stack.index(id)..stack.length)
  super('Circular reference detected!')
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/wcc/contentful/exceptions.rb', line 15

def id
  @id
end

#stackObject (readonly)

Returns the value of attribute stack.



15
16
17
# File 'lib/wcc/contentful/exceptions.rb', line 15

def stack
  @stack
end

Instance Method Details

#messageObject



23
24
25
26
27
28
29
# File 'lib/wcc/contentful/exceptions.rb', line 23

def message
  return super unless stack

  super + "\n  " \
          "#{stack.last} points to #{id} which is also it's ancestor\n  " +
    stack.join('->')
end