Exception: Roby::ChildFailedError

Inherits:
RelationFailedError show all
Defined in:
lib/roby/task_structure/dependency.rb

Overview

This exception is raised when a hierarchy relation fails

Instance Attribute Summary collapse

Attributes inherited from RelationFailedError

#parent

Attributes inherited from LocalizedError

#failed_event, #failed_generator, #failed_task, #failure_point

Attributes inherited from ExceptionBase

#original_exceptions

Instance Method Summary collapse

Methods inherited from LocalizedError

#fatal?, match, #propagated?, #to_execution_exception, to_execution_exception_matcher

Methods included from DRoby::V5::LocalizedErrorDumper

#droby_dump

Methods inherited from ExceptionBase

#each_original_exception, #report_exceptions_from

Methods included from DRoby::V5::ExceptionBaseDumper

#droby_dump

Methods included from DRoby::V5::Builtins::ExceptionDumper

#droby_dump

Constructor Details

#initialize(parent, child, explanation, mode) ⇒ ChildFailedError

Returns a new instance of ChildFailedError.



893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'lib/roby/task_structure/dependency.rb', line 893

def initialize(parent, child, explanation, mode)
    @explanation = explanation
    @mode = mode

    events, generators, others = [], [], []
    explanation.elements.each do |e|
        case e
        when Event then events << e
        when EventGenerator then generators << e
        else others << e
        end
    end

    failure_point =
        if events.size > 2 || !others.empty?
            child
        else
            base_event = events.first || generators.first
            if explanation.value.nil? # unreachability
                reason = base_event.unreachability_reason
                if reason.respond_to?(:task) && reason.task == child
                    reason
                else
                    base_event
                end
            elsif base_event.respond_to?(:root_task_sources)
                sources = base_event.root_task_sources
                if sources.size == 1
                    sources.first
                else
                    base_event
                end
            else
                base_event
            end
        end

    super(failure_point)

    report_exceptions_from(explanation)
    @parent   = parent
    @relation = parent[child, TaskStructure::Dependency]
    if @relation
        @relation = @relation.dup
    end
end

Instance Attribute Details

#explanationObject (readonly)

The Explanation object that describes why the relation failed



888
889
890
# File 'lib/roby/task_structure/dependency.rb', line 888

def explanation
  @explanation
end

#modeSymbol (readonly)

Returns the fault mode. It can either be :failed_event or :unreachable_success.

Returns:

  • (Symbol)

    the fault mode. It can either be :failed_event or :unreachable_success



891
892
893
# File 'lib/roby/task_structure/dependency.rb', line 891

def mode
  @mode
end

#relationObject (readonly)

The relation parameters (i.e. the hash given to #depends_on)



886
887
888
# File 'lib/roby/task_structure/dependency.rb', line 886

def relation
  @relation
end

Instance Method Details

#backtraceObject



956
957
958
# File 'lib/roby/task_structure/dependency.rb', line 956

def backtrace
    []
end

#childObject

The child in the relation



882
883
884
# File 'lib/roby/task_structure/dependency.rb', line 882

def child
    failed_task
end

#involved_plan_object?(obj) ⇒ Boolean

True if obj is involved in this exception

Returns:

  • (Boolean)


961
962
963
# File 'lib/roby/task_structure/dependency.rb', line 961

def involved_plan_object?(obj)
    super || obj == parent
end

#pretty_print(pp) ⇒ Object

:nodoc:



940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/roby/task_structure/dependency.rb', line 940

def pretty_print(pp) # :nodoc:
    child.pretty_print(pp)
    pp.breakable
    pp.text "child '#{relation[:roles].to_a.join(', ')}' of "
    parent.pretty_print(pp)
    pp.breakable
    pp.breakable
    case mode
    when :failed_event
        pp.text "Child triggered the failure predicate '#{relation[:failure]}': "
    when :unreachable_success
        pp.text "success condition can no longer be reached '#{relation[:success]}': "
    end
    explanation.pretty_print(pp, context_task: child)
end