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

exception[R]

The exception object

generator[R]

The origin EventGenerator if there is one

handled[RW]

If this specific exception has been marked has handled

trace[R]

The trace of how this exception has been propagated in the plan so far

@return [Relations::BidirectionalDirectedAdjacencyGraph]

Public Class Methods

new(exception) click to toggle source

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

each_involved_task(&block) click to toggle source

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
fatal?() click to toggle source

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
fork() click to toggle source

Create a sibling from this exception

# File lib/roby/exceptions.rb, line 108
def fork
    dup
end
handled?() click to toggle source

If this exception has been marked as handled

# File lib/roby/exceptions.rb, line 61
def handled?
    handled
end
initialize_copy(from) click to toggle source
Calls superclass method
# File lib/roby/exceptions.rb, line 127
def initialize_copy(from)
    super
    @trace = from.trace.dup
end
involved_task?(task) click to toggle source
# File lib/roby/exceptions.rb, line 71
def involved_task?(task)
    trace.has_vertex?(task)
end
merge(sibling) click to toggle source

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
origin() click to toggle source

The object from which the exception originates

# File lib/roby/exceptions.rb, line 48
def origin; @origin end
originates_from?(object) click to toggle source

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
pretty_print(pp) click to toggle source
# 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
propagate(from, to) click to toggle source
# File lib/roby/exceptions.rb, line 112
def propagate(from, to)
    trace.add_edge(from, to)
end
propagation_leafs() click to toggle source

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
reset_trace() click to toggle source

Resets the trace to [origin]

# File lib/roby/exceptions.rb, line 76
def reset_trace
    @trace = Relations::BidirectionalDirectedAdjacencyGraph.new
    @trace.add_vertex(@origin)
end
to_execution_exception() click to toggle source
# File lib/roby/exceptions.rb, line 132
def to_execution_exception
    self
end
to_s() click to toggle source
# File lib/roby/exceptions.rb, line 136
def to_s
    PP.pp(self, '')
end