module Roby::TaskStructure::ErrorHandling::Extension
Public Instance Methods
Test
if this task has an active repair tasks associated
# File lib/roby/task_structure/error_handling.rb, line 107 def being_repaired? each_child_object(ErrorHandling).any? { |t| t.running? } end
Tests if this task can handle the provided exception, either because it is an error repair task itself, or because it has one attached.
It is different from {#handles_error?} as the latter tests whether this task is currently handling the exception, while this one only tests if it could (usually, the difference is whether this task is running)
@return [Boolean]
# File lib/roby/task_structure/error_handling.rb, line 88 def can_handle_error?(exception) exception = exception.to_execution_exception can_repair_error?(exception) || !find_all_matching_repair_tasks(exception).empty? end
Tests if this task can be used to repair an exception
It is different from {#repairs_error?} as the latter tests whether this task is currently repairing such an exception, while this one only tests if it could (usually, the difference is whether this task is running)
@return [Boolean]
# File lib/roby/task_structure/error_handling.rb, line 47 def can_repair_error?(exception) return if finished? exception = exception.to_execution_exception repaired_tasks.each do |repaired| matchers = repaired[self, ErrorHandling] if matchers.any? { |m| m === exception } return true end end false end
# File lib/roby/task_structure/error_handling.rb, line 34 def failed_task # For backward compatibility only. One should use #repaired_tasks repaired_tasks.first end
Returns the set of repair tasks attached to self that match the given exception
# File lib/roby/task_structure/error_handling.rb, line 69 def find_all_matching_repair_tasks(exception) exception = exception.to_execution_exception result = [] each_error_handler do |child, matchers| next if child.finished? result << child if matchers.any? { |m| m === exception } end result end
Tests if this task is currently handling the provided exception, either because it is an error repair task itself, or because it has one attached.
@return [Boolean]
# File lib/roby/task_structure/error_handling.rb, line 99 def handles_error?(exception) return if !plan exception = exception.to_execution_exception ((running? || starting?) && can_repair_error?(exception)) || find_all_matching_repair_tasks(exception).any? { |t| t.starting? || t.running? } end
# File lib/roby/task_structure/error_handling.rb, line 30 def repaired_tasks each_parent_object(ErrorHandling).to_a end
Tests whether the given exception is handled by this task or by a repair handler attached to this task
# File lib/roby/task_structure/error_handling.rb, line 62 def repairs_error?(exception) exception = exception.to_execution_exception running? && can_repair_error?(exception) end