class Roby::ExecutionException
ExecutionException
objects are used during the exception handling stage to keep information about the propagation.
When a propagation fork is found (for instance, a task with two parents), two or more siblings are created with fork
. If at some point two siblings are to be handled by the same task, coming for instance from two different children, then they are merged with merge
to from one single ExecutionException
object.
Attributes
The exception object
The origin EventGenerator
if there is one
If this specific exception has been marked has handled
The trace of how this exception has been propagated in the plan so far
@return [Relations::BidirectionalDirectedAdjacencyGraph]
Public Class Methods
Creates a new execution exception object with the specified source If source
is nil, tries to guess the source from exception
: if exception
responds to task or generator
we use either task or call generator
.task
# File lib/roby/exceptions.rb, line 90 def initialize(exception) @exception = exception @trace = Relations::BidirectionalDirectedAdjacencyGraph.new if task = exception.failed_task @origin = task @trace.add_vertex(task) end if generator = exception.failed_generator @generator = exception.failed_generator end if !task && !generator raise ArgumentError, "invalid exception specification: cannot get the exception source" end end
Public Instance Methods
Enumerates all tasks that are involved in this exception (either origin or in the trace)
# File lib/roby/exceptions.rb, line 66 def each_involved_task(&block) return enum_for(__method__) if !block_given? trace.each_vertex(&block) end
If true, the underlying exception is a fatal error, i.e. should cause parent tasks to be stopped if unhandled.
# File lib/roby/exceptions.rb, line 51 def fatal?; exception.fatal? end
Create a sibling from this exception
# File lib/roby/exceptions.rb, line 108 def fork dup end
If this exception has been marked as handled
# File lib/roby/exceptions.rb, line 61 def handled? handled end
# File lib/roby/exceptions.rb, line 127 def initialize_copy(from) super @trace = from.trace.dup end
# File lib/roby/exceptions.rb, line 71 def involved_task?(task) trace.has_vertex?(task) end
Merges sibling
into this object
@param [Roby::Task] edge_source the source of the edge in sibling that
led to this merge
@param [Roby::Task] edge_target the target of the edge in sibling that
led to this merge
# File lib/roby/exceptions.rb, line 122 def merge(sibling) @trace.merge(sibling.trace) self end
The object from which the exception originates
# File lib/roby/exceptions.rb, line 48 def origin; @origin end
True if this exception originates from the given task or generator
# File lib/roby/exceptions.rb, line 82 def originates_from?(object) generator == object || origin == object end
# File lib/roby/exceptions.rb, line 140 def pretty_print(pp) pp.text "from #{origin} with trace " pp.nest(2) do pp.nest(2) do trace.each_edge do |a, b, _| pp.breakable pp.text "#{a} => #{b}" end end pp.breakable pp.text "Exception:" pp.nest(2) do pp.breakable exception.pretty_print(pp) end end end
# File lib/roby/exceptions.rb, line 112 def propagate(from, to) trace.add_edge(from, to) end
The last object(s) that handled the exception. This is either a single object or an array
# File lib/roby/exceptions.rb, line 46 def propagation_leafs; trace.each_vertex.find_all { |v| trace.leaf?(v) } end
Resets the trace to [origin]
# File lib/roby/exceptions.rb, line 76 def reset_trace @trace = Relations::BidirectionalDirectedAdjacencyGraph.new @trace.add_vertex(@origin) end
# File lib/roby/exceptions.rb, line 132 def to_execution_exception self end
# File lib/roby/exceptions.rb, line 136 def to_s PP.pp(self, '') end