Exception: Roby::LocalizedError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/roby/standard_errors.rb

Overview

This kind of errors are generated during the plan execution, allowing to blame a fault on a plan object (#failure_point). The precise failure point is categorized in the #failed_event, #failed_generator and #failed_task. It is guaranteed that one of #failed_generator and #failed_task is non-nil.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(failure_point) ⇒ LocalizedError

Create a LocalizedError object with the given failure point



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/roby/standard_errors.rb', line 16

def initialize(failure_point)
    @failure_point = failure_point
    if failure_point.kind_of?(Event)
	@failed_event = failure_point
	@failed_generator = failure_point.generator
    elsif failure_point.kind_of?(EventGenerator)
	@failed_generator = failure_point
    elsif failure_point.kind_of?(Task)
	@failed_task = failure_point
    end

    if !@failed_task && @failed_generator && @failed_generator.respond_to?(:task)
	@failed_task = failed_generator.task
    end
    if !@failed_task && !@failed_generator
	raise ArgumentError, "cannot deduce a task and/or a generator from #{failure_point}"
    end

           super("")
end

Instance Attribute Details

#failed_eventObject (readonly)

The objects of the given categories which are related to #failure_point



13
14
15
# File 'lib/roby/standard_errors.rb', line 13

def failed_event
  @failed_event
end

#failed_generatorObject (readonly)

The objects of the given categories which are related to #failure_point



13
14
15
# File 'lib/roby/standard_errors.rb', line 13

def failed_generator
  @failed_generator
end

#failed_taskObject (readonly)

The objects of the given categories which are related to #failure_point



13
14
15
# File 'lib/roby/standard_errors.rb', line 13

def failed_task
  @failed_task
end

#failure_pointObject (readonly)

The object describing the point of failure



10
11
12
# File 'lib/roby/standard_errors.rb', line 10

def failure_point
  @failure_point
end

Instance Method Details

#involved_plan_object?(obj) ⇒ Boolean

True if obj is involved in this error

Returns:

  • (Boolean)


51
52
53
54
55
56
# File 'lib/roby/standard_errors.rb', line 51

def involved_plan_object?(obj)
    obj.kind_of?(PlanObject) && 
        (obj == failed_event ||
         obj == failed_generator ||
         obj == failed_task)
end

#pretty_print(pp) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/roby/standard_errors.rb', line 37

def pretty_print(pp)
	    pp.text "#{self.class.name}"
    if !message.empty?
        pp.text ": #{message}"
    end
    pp.breakable
    failure_point.pretty_print(pp)

    if backtrace && !backtrace.empty?
        Roby.pretty_print_backtrace(pp, backtrace)
    end
end