Exception: Roby::ChildFailedError
- Inherits:
-
RelationFailedError
- Object
- RuntimeError
- ExceptionBase
- LocalizedError
- RelationFailedError
- Roby::ChildFailedError
- Defined in:
- lib/roby/task_structure/dependency.rb
Overview
This exception is raised when a hierarchy relation fails
Instance Attribute Summary collapse
-
#explanation ⇒ Object
readonly
The Explanation object that describes why the relation failed.
-
#mode ⇒ Symbol
readonly
The fault mode.
-
#relation ⇒ Object
readonly
The relation parameters (i.e. the hash given to #depends_on).
Attributes inherited from RelationFailedError
Attributes inherited from LocalizedError
#failed_event, #failed_generator, #failed_task, #failure_point
Attributes inherited from ExceptionBase
Instance Method Summary collapse
- #backtrace ⇒ Object
-
#child ⇒ Object
The child in the relation.
-
#initialize(parent, child, explanation, mode) ⇒ ChildFailedError
constructor
A new instance of ChildFailedError.
-
#involved_plan_object?(obj) ⇒ Boolean
True if
objis involved in this exception. -
#pretty_print(pp) ⇒ Object
:nodoc:.
Methods inherited from LocalizedError
#fatal?, match, #propagated?, #to_execution_exception, to_execution_exception_matcher
Methods included from DRoby::V5::LocalizedErrorDumper
Methods inherited from ExceptionBase
#each_original_exception, #report_exceptions_from
Methods included from DRoby::V5::ExceptionBaseDumper
Methods included from DRoby::V5::Builtins::ExceptionDumper
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
#explanation ⇒ Object (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 |
#mode ⇒ Symbol (readonly)
Returns 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 |
#relation ⇒ Object (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
#backtrace ⇒ Object
990 991 992 |
# File 'lib/roby/task_structure/dependency.rb', line 990 def backtrace [] end |
#child ⇒ Object
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
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 |