Exception: Ast::Merge::PlaceholderCollisionError

Inherits:
Error
  • Object
show all
Defined in:
lib/ast/merge.rb

Overview

Raised when the document contains text that matches the region placeholder.

Region placeholders are used internally to mark positions in a document where nested regions will be substituted after merging. If the document already contains text that looks like a placeholder, the merge cannot proceed safely.

Examples:

Handling placeholder collision

begin
  merger = SmartMerger.new(template, destination, regions: [...])
rescue Ast::Merge::PlaceholderCollisionError => e
  # Use a custom placeholder to avoid the collision
  merger = SmartMerger.new(template, destination,
    regions: [...],
    region_placeholder: "###MY_CUSTOM_PLACEHOLDER_"
  )
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(placeholder) ⇒ PlaceholderCollisionError

Initialize a new PlaceholderCollisionError.

Parameters:

  • placeholder (String)

    The placeholder string that was found in the document



130
131
132
133
134
135
136
# File 'lib/ast/merge.rb', line 130

def initialize(placeholder)
  @placeholder = placeholder
  super(
    "Document contains placeholder text '#{placeholder}'. " \
      "Use the :region_placeholder option to specify a custom placeholder."
  )
end

Instance Attribute Details

#placeholderString (readonly)

Returns The placeholder that caused the collision.

Returns:

  • (String)

    The placeholder that caused the collision



125
126
127
# File 'lib/ast/merge.rb', line 125

def placeholder
  @placeholder
end