Exception: Synthra::Errors::ValidationError

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

Overview

Base class for Simulyra DSL validation errors

ValidationError provides structured error messages with suggestions for how to fix the problem.

Constant Summary collapse

ERROR_CODE =
"VALIDATION_ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, line: nil, suggestion: nil, **kwargs) ⇒ ValidationError

Create a new ValidationError

Parameters:

  • message (String)

    error description

  • line (Integer, nil) (defaults to: nil)

    line number where error occurred

  • suggestion (String, nil) (defaults to: nil)

    suggestion for fixing the error



483
484
485
486
487
488
# File 'lib/synthra/errors.rb', line 483

def initialize(message, line: nil, suggestion: nil, **kwargs)
  @suggestion = suggestion
  full_message = message
  full_message += " -> #{suggestion}" if suggestion
  super(full_message, line: line, **kwargs)
end

Instance Attribute Details

#suggestionString? (readonly)

Returns suggestion for how to fix the error.

Returns:

  • (String, nil)

    suggestion for how to fix the error



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/synthra/errors.rb', line 473

class ValidationError < ParseError
  ERROR_CODE = "VALIDATION_ERROR"
  attr_reader :suggestion

  # Create a new ValidationError
  #
  # @param message [String] error description
  # @param line [Integer, nil] line number where error occurred
  # @param suggestion [String, nil] suggestion for fixing the error
  #
  def initialize(message, line: nil, suggestion: nil, **kwargs)
    @suggestion = suggestion
    full_message = message
    full_message += " -> #{suggestion}" if suggestion
    super(full_message, line: line, **kwargs)
  end
end