Exception: Synthra::Errors::FieldOrderError
- Inherits:
-
ParseError
- Object
- StandardError
- Error
- ParseError
- Synthra::Errors::FieldOrderError
- Defined in:
- lib/synthra/errors.rb
Overview
Field order error for copy() references
Raised when a copy() field references another field that is defined after it in the schema. Since fields are generated in definition order, this would result in nil values.
Constant Summary collapse
- ERROR_CODE =
"FIELD_ORDER_ERROR"
Instance Attribute Summary collapse
-
#copy_path ⇒ String
readonly
The path being copied.
-
#field_name ⇒ String
readonly
The name of the copy field.
-
#schema_name ⇒ String
readonly
The schema containing the error.
Instance Method Summary collapse
-
#initialize(field_name:, copy_path:, schema_name:, suggestion: nil, **kwargs) ⇒ FieldOrderError
constructor
Create a new FieldOrderError.
Constructor Details
#initialize(field_name:, copy_path:, schema_name:, suggestion: nil, **kwargs) ⇒ FieldOrderError
Create a new FieldOrderError
378 379 380 381 382 383 384 385 386 387 |
# File 'lib/synthra/errors.rb', line 378 def initialize(field_name:, copy_path:, schema_name:, suggestion: nil, **kwargs) @field_name = field_name @copy_path = copy_path @schema_name = schema_name = "Field order error in '#{schema_name}': " \ "'#{field_name}' uses copy(\"#{copy_path}\") but the source field is defined after it" super(, suggestions: suggestion ? [suggestion] : nil, **kwargs) end |
Instance Attribute Details
#copy_path ⇒ String (readonly)
Returns the path being copied.
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/synthra/errors.rb', line 364 class FieldOrderError < ParseError ERROR_CODE = "FIELD_ORDER_ERROR" attr_reader :field_name, :copy_path, :schema_name # Create a new FieldOrderError # # @param field_name [String] the copy field name # @param copy_path [String] the path being copied # @param schema_name [String] the schema name # @param suggestion [String] how to fix the error # @param kwargs [Hash] additional options # def initialize(field_name:, copy_path:, schema_name:, suggestion: nil, **kwargs) @field_name = field_name @copy_path = copy_path @schema_name = schema_name = "Field order error in '#{schema_name}': " \ "'#{field_name}' uses copy(\"#{copy_path}\") but the source field is defined after it" super(, suggestions: suggestion ? [suggestion] : nil, **kwargs) end end |
#field_name ⇒ String (readonly)
Returns the name of the copy field.
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/synthra/errors.rb', line 364 class FieldOrderError < ParseError ERROR_CODE = "FIELD_ORDER_ERROR" attr_reader :field_name, :copy_path, :schema_name # Create a new FieldOrderError # # @param field_name [String] the copy field name # @param copy_path [String] the path being copied # @param schema_name [String] the schema name # @param suggestion [String] how to fix the error # @param kwargs [Hash] additional options # def initialize(field_name:, copy_path:, schema_name:, suggestion: nil, **kwargs) @field_name = field_name @copy_path = copy_path @schema_name = schema_name = "Field order error in '#{schema_name}': " \ "'#{field_name}' uses copy(\"#{copy_path}\") but the source field is defined after it" super(, suggestions: suggestion ? [suggestion] : nil, **kwargs) end end |
#schema_name ⇒ String (readonly)
Returns the schema containing the error.
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/synthra/errors.rb', line 364 class FieldOrderError < ParseError ERROR_CODE = "FIELD_ORDER_ERROR" attr_reader :field_name, :copy_path, :schema_name # Create a new FieldOrderError # # @param field_name [String] the copy field name # @param copy_path [String] the path being copied # @param schema_name [String] the schema name # @param suggestion [String] how to fix the error # @param kwargs [Hash] additional options # def initialize(field_name:, copy_path:, schema_name:, suggestion: nil, **kwargs) @field_name = field_name @copy_path = copy_path @schema_name = schema_name = "Field order error in '#{schema_name}': " \ "'#{field_name}' uses copy(\"#{copy_path}\") but the source field is defined after it" super(, suggestions: suggestion ? [suggestion] : nil, **kwargs) end end |