Exception: Synthra::Errors::CycleError

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

Overview

Circular schema reference detected

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

Examples:

Circular reference

# Parent:
#   child: Child
# Child:
#   parent: Parent  <- Circular!

Constant Summary collapse

ERROR_CODE =
"CYCLE_ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cycle, **kwargs) ⇒ CycleError

Create a new CycleError

Parameters:

  • cycle (Array<String>)

    list of schema names in the cycle

  • kwargs (Hash)

    additional options



335
336
337
338
339
# File 'lib/synthra/errors.rb', line 335

def initialize(cycle, **kwargs)
  @cycle = cycle
  cycle_path = cycle.join(" -> ")
  super("Circular schema reference detected: #{cycle_path}", **kwargs)
end

Instance Attribute Details

#cycleArray<String> (readonly)

Returns the schemas involved in the cycle.

Returns:

  • (Array<String>)

    the schemas involved in the cycle



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/synthra/errors.rb', line 324

class CycleError < ParseError
  ERROR_CODE = "CYCLE_ERROR"
  attr_reader :cycle


  # Create a new CycleError
  #
  # @param cycle [Array<String>] list of schema names in the cycle
  # @param kwargs [Hash] additional options
  #

  def initialize(cycle, **kwargs)
    @cycle = cycle
    cycle_path = cycle.join(" -> ")
    super("Circular schema reference detected: #{cycle_path}", **kwargs)
  end
end