Exception: Synthra::Errors::CyclicReferenceError

Inherits:
GenerationError show all
Defined in:
lib/synthra/errors.rb

Overview

Cyclic reference detected between schemas

Raised when schemas reference each other in a cycle, which would cause infinite recursion during generation.

Examples:

# User references Order, Order references User
# CyclicReferenceError: Cyclic reference detected: User -> Order -> User

Constant Summary collapse

ERROR_CODE =
"CYCLIC_REFERENCE_ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cycle) ⇒ CyclicReferenceError

Create a new CyclicReferenceError

Parameters:

  • cycle (Array<String>)

    the schema names in the reference cycle



676
677
678
679
680
# File 'lib/synthra/errors.rb', line 676

def initialize(cycle)
  @cycle = cycle
  cycle_str = cycle.join(" -> ")
  super("Cyclic reference detected: #{cycle_str}")
end

Instance Attribute Details

#cycleArray<String> (readonly)

Returns the schema names forming the cycle.

Returns:

  • (Array<String>)

    the schema names forming the cycle



666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
# File 'lib/synthra/errors.rb', line 666

class CyclicReferenceError < GenerationError
  ERROR_CODE = "CYCLIC_REFERENCE_ERROR"
  attr_reader :cycle


  # Create a new CyclicReferenceError
  #
  # @param cycle [Array<String>] the schema names in the reference cycle
  #

  def initialize(cycle)
    @cycle = cycle
    cycle_str = cycle.join(" -> ")
    super("Cyclic reference detected: #{cycle_str}")
  end
end