Module: Roby::ExceptionHandlingObject
- Included in:
- ExecutablePlan, Task
- 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
Defined Under Namespace
Modules: ClassExtension
Instance Method Summary collapse
- #add_error(error, propagate_through: nil) ⇒ Object
-
#handle_exception(exception_object) ⇒ Object
Calls the exception handlers defined in this task for
exception_object.exceptionReturns true if the exception has been handled, false otherwise. -
#pass_exception ⇒ Object
To be used in exception handlers themselves.
Instance Method Details
#add_error(error, propagate_through: nil) ⇒ Object
176 177 178 |
# File 'lib/roby/exceptions.rb', line 176 def add_error(error, propagate_through: nil) execution_engine.add_error(error, propagate_through: propagate_through) end |
#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
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/roby/exceptions.rb', line 182 def handle_exception(exception_object) each_exception_handler do |matcher, handler| if exception_object.exception.kind_of?(FailedExceptionHandler) # Do not handle a failed exception handler by itself next if exception_object.exception.handler == handler end if matcher === exception_object catch(:next_exception_handler) do begin handler.call(self, exception_object) return true rescue Exception => e if !kind_of?(PlanObject) execution_engine.add_framework_error(e, 'global exception handling') else add_error(FailedExceptionHandler.new(e, self, exception_object, handler)) end end end end end return false end |
#pass_exception ⇒ Object
To be used in exception handlers themselves. Passes the exception to the next matching exception handler
172 173 174 |
# File 'lib/roby/exceptions.rb', line 172 def pass_exception throw :next_exception_handler end |