Exception: Synthra::Errors::PathError

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

Overview

Invalid path in copy() reference

Raised when a copy() type references a path that doesn't exist in the schema structure. Includes "did you mean" suggestions for similar paths.

Examples:

# copy("users.snder.id")  <- PathError: Path 'users.snder.id' not found.
#                            Did you mean: users.sender.id?

Constant Summary collapse

ERROR_CODE =
"PATH_ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, available_paths: [], suggestions: nil, **kwargs) ⇒ PathError

Create a new PathError

Parameters:

  • path (String)

    the path that wasn't found

  • available_paths (Array<String>) (defaults to: [])

    list of valid paths

  • suggestions (Array<String>) (defaults to: nil)

    similar paths

  • kwargs (Hash)

    location information (line, column, source_line)



301
302
303
304
305
# File 'lib/synthra/errors.rb', line 301

def initialize(path, available_paths: [], suggestions: nil, **kwargs)
  @path = path
  @available_paths = available_paths
  super("Path '#{path}' not found in schema", suggestions: suggestions, **kwargs)
end

Instance Attribute Details

#available_pathsArray<String> (readonly)

Returns list of valid paths available.

Returns:

  • (Array<String>)

    list of valid paths available



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/synthra/errors.rb', line 288

class PathError < ParseError
  ERROR_CODE = "PATH_ERROR"
  attr_reader :path, :available_paths


  # Create a new PathError
  #
  # @param path [String] the path that wasn't found
  # @param available_paths [Array<String>] list of valid paths
  # @param suggestions [Array<String>] similar paths
  # @param kwargs [Hash] location information (line, column, source_line)
  #

  def initialize(path, available_paths: [], suggestions: nil, **kwargs)
    @path = path
    @available_paths = available_paths
    super("Path '#{path}' not found in schema", suggestions: suggestions, **kwargs)
  end
end

#pathString (readonly)

Returns the invalid path that was referenced.

Returns:

  • (String)

    the invalid path that was referenced



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/synthra/errors.rb', line 288

class PathError < ParseError
  ERROR_CODE = "PATH_ERROR"
  attr_reader :path, :available_paths


  # Create a new PathError
  #
  # @param path [String] the path that wasn't found
  # @param available_paths [Array<String>] list of valid paths
  # @param suggestions [Array<String>] similar paths
  # @param kwargs [Hash] location information (line, column, source_line)
  #

  def initialize(path, available_paths: [], suggestions: nil, **kwargs)
    @path = path
    @available_paths = available_paths
    super("Path '#{path}' not found in schema", suggestions: suggestions, **kwargs)
  end
end