Module: Roby::ExceptionHandlingObject

Included in:
Roby
Defined in:
lib/roby/exceptions.rb

Overview

This module is to be included in all objects that are able to handle exception. These objects should define

#each_exception_handler { |matchers, handler| ... }

See Task::on_exception and Task#on_exception

Instance Method Summary collapse

Instance Method Details

#handle_exception(exception_object) ⇒ Object

Calls the exception handlers defined in this task for exception_object.exception Returns true if the exception has been handled, false otherwise



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/roby/exceptions.rb', line 125

def handle_exception(exception_object)
    each_exception_handler do |matchers, handler|
  if matchers.find { |m| m === exception_object.exception }
      catch(:next_exception_handler) do 
    begin
        handler.call(self, exception_object)
        return true
    rescue Exception => e
        if self == Roby
      Propagation.add_framework_error(e, 'global exception handling')
        else
      Propagation.add_error(FailedExceptionHandler.new(e, self, exception_object))
        end
    end
      end
  end
    end
    return false
end

#pass_exceptionObject

To be used in exception handlers themselves. Passes the exception to the next matching exception handler



119
120
121
# File 'lib/roby/exceptions.rb', line 119

def pass_exception
    throw :next_exception_handler
end