Exception: Roby::NoSuchChild

Inherits:
ArgumentError
  • Object
show all
Defined in:
lib/roby/standard_errors.rb

Overview

Exception raised when a child is being resolved by role, but the role is not associated with any child

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, role, known_children) ⇒ NoSuchChild

Returns a new instance of NoSuchChild.



584
585
586
587
588
# File 'lib/roby/standard_errors.rb', line 584

def initialize(object, role, known_children)
    super()

    @object, @role, @known_children = object, role, known_children
end

Instance Attribute Details

#known_children{String=>Object} (readonly)

Returns the set of known children.

Returns:

  • ({String=>Object})

    the set of known children



582
583
584
# File 'lib/roby/standard_errors.rb', line 582

def known_children
  @known_children
end

#objectObject (readonly)

Returns the object whose children we try to access.

Returns:

  • (Object)

    the object whose children we try to access



578
579
580
# File 'lib/roby/standard_errors.rb', line 578

def object
  @object
end

#roleString (readonly)

Returns the role that failed to be resolved.

Returns:

  • (String)

    the role that failed to be resolved



580
581
582
# File 'lib/roby/standard_errors.rb', line 580

def role
  @role
end

Instance Method Details

#pretty_print(pp) ⇒ Object



590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'lib/roby/standard_errors.rb', line 590

def pretty_print(pp)
    pp.text "#{object} has no child with the role '#{role}'"

    if known_children.empty?
        pp.text ", actually, it has no child at all"
    else
        pp.text ". Known children:"
        pp.nest(2) do
            known_children.each do |role, child|
                pp.breakable
                pp.text "#{role}: #{child}"
            end
        end
    end
end