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.



927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
# File 'lib/roby/task_structure/dependency.rb', line 927

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



922
923
924
# File 'lib/roby/task_structure/dependency.rb', line 922

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



925
926
927
# File 'lib/roby/task_structure/dependency.rb', line 925

def mode
  @mode
end

#relationObject (readonly)

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



920
921
922
# File 'lib/roby/task_structure/dependency.rb', line 920

def relation
  @relation
end

Instance Method Details

#backtraceObject



990
991
992
# File 'lib/roby/task_structure/dependency.rb', line 990

def backtrace
    []
end

#childObject

The child in the relation



916
917
918
# File 'lib/roby/task_structure/dependency.rb', line 916

def child
    failed_task
end

#involved_plan_object?(obj) ⇒ Boolean

True if obj is involved in this exception

Returns:

  • (Boolean)


995
996
997
# File 'lib/roby/task_structure/dependency.rb', line 995

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

#pretty_print(pp) ⇒ Object

:nodoc:



974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
# File 'lib/roby/task_structure/dependency.rb', line 974

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