Exception: Synthra::Errors::MissingReferenceError

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

Overview

Referenced schema or field not found

Raised when a Ref() references a schema or field that doesn't exist.

Examples:

# user_id: Ref(NonExistent.id)
# MissingReferenceError: Reference not found: NonExistent.id

Constant Summary collapse

ERROR_CODE =
"MISSING_REFERENCE_ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_name:, field_path: nil) ⇒ MissingReferenceError

Create a new MissingReferenceError

Parameters:

  • schema_name (String)

    the schema name that wasn't found

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

    the field path if referencing a specific field



710
711
712
713
714
715
716
717
718
719
720
# File 'lib/synthra/errors.rb', line 710

def initialize(schema_name:, field_path: nil)
  @schema_name = schema_name
  @field_path = field_path

  message = if field_path
              "Reference not found: #{schema_name}.#{field_path}"
            else
              "Schema not found: #{schema_name}"
            end
  super(message)
end

Instance Attribute Details

#field_pathString? (readonly)

Returns the field path within the schema (if applicable).

Returns:

  • (String, nil)

    the field path within the schema (if applicable)



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
# File 'lib/synthra/errors.rb', line 699

class MissingReferenceError < GenerationError
  ERROR_CODE = "MISSING_REFERENCE_ERROR"
  attr_reader :schema_name, :field_path


  # Create a new MissingReferenceError
  #
  # @param schema_name [String] the schema name that wasn't found
  # @param field_path [String, nil] the field path if referencing a specific field
  #

  def initialize(schema_name:, field_path: nil)
    @schema_name = schema_name
    @field_path = field_path

    message = if field_path
                "Reference not found: #{schema_name}.#{field_path}"
              else
                "Schema not found: #{schema_name}"
              end
    super(message)
  end
end

#schema_nameString (readonly)

Returns the schema name that was referenced.

Returns:

  • (String)

    the schema name that was referenced



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
# File 'lib/synthra/errors.rb', line 699

class MissingReferenceError < GenerationError
  ERROR_CODE = "MISSING_REFERENCE_ERROR"
  attr_reader :schema_name, :field_path


  # Create a new MissingReferenceError
  #
  # @param schema_name [String] the schema name that wasn't found
  # @param field_path [String, nil] the field path if referencing a specific field
  #

  def initialize(schema_name:, field_path: nil)
    @schema_name = schema_name
    @field_path = field_path

    message = if field_path
                "Reference not found: #{schema_name}.#{field_path}"
              else
                "Schema not found: #{schema_name}"
              end
    super(message)
  end
end