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
191 192 193 |
# File 'lib/roby/exceptions.rb', line 191 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
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/roby/exceptions.rb', line 197 def handle_exception(exception_object) each_exception_handler do |matcher, handler| if exception_object.exception.kind_of?(FailedExceptionHandler) && exception_object.exception.handler == handler # Do not handle a failed exception handler by itself next 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 false end |
#pass_exception ⇒ Object
To be used in exception handlers themselves. Passes the exception to the next matching exception handler
187 188 189 |
# File 'lib/roby/exceptions.rb', line 187 def pass_exception throw :next_exception_handler end |