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.
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 939 940 941 942 943 |
# File 'lib/roby/task_structure/dependency.rb', line 898 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
893 894 895 |
# File 'lib/roby/task_structure/dependency.rb', line 893 def explanation @explanation end |
#mode ⇒ Symbol (readonly)
Returns the fault mode. It can either be :failed_event or :unreachable_success.
896 897 898 |
# File 'lib/roby/task_structure/dependency.rb', line 896 def mode @mode end |
#relation ⇒ Object (readonly)
The relation parameters (i.e. the hash given to #depends_on)
891 892 893 |
# File 'lib/roby/task_structure/dependency.rb', line 891 def relation @relation end |
Instance Method Details
#backtrace ⇒ Object
961 962 963 |
# File 'lib/roby/task_structure/dependency.rb', line 961 def backtrace [] end |
#child ⇒ Object
The child in the relation
887 888 889 |
# File 'lib/roby/task_structure/dependency.rb', line 887 def child failed_task end |
#involved_plan_object?(obj) ⇒ Boolean
True if obj is involved in this exception
966 967 968 |
# File 'lib/roby/task_structure/dependency.rb', line 966 def involved_plan_object?(obj) super || obj == parent end |
#pretty_print(pp) ⇒ Object
:nodoc:
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
# File 'lib/roby/task_structure/dependency.rb', line 945 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 |