Module: StateFlow::ExceptionHandlerClient
- Included in:
- Event, EventClient
- Defined in:
- lib/state_flow/exception_handler_client.rb
Instance Method Summary collapse
-
#exception_handlers ⇒ Object
例外ハンドラの配列を返します。 StateFlow::Stateはこれを上書きして親のハンドラも含めて返します。.
- #exception_handling(context, &block) ⇒ Object
Instance Method Details
#exception_handlers ⇒ Object
例外ハンドラの配列を返します。 StateFlow::Stateはこれを上書きして親のハンドラも含めて返します。
8 9 10 |
# File 'lib/state_flow/exception_handler_client.rb', line 8 def exception_handlers events.select{|ev| ev.is_a?(ExceptionHandler)} end |
#exception_handling(context, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/state_flow/exception_handler_client.rb', line 12 def exception_handling(context, &block) if context.force_recovering? return context.with_force_recovering(self, :retry_in_recovering, context, &block) end handlers = exception_handlers return yield if handlers.empty? ActiveRecord::Base.logger.debug("---- exception_handling BEGIN by #{self.inspect}") begin return yield ActiveRecord::Base.logger.debug("---- exception_handling END by #{self.inspect}") rescue Exception => exception context.exceptions << exception context.trace(exception) if recover_handler = handlers.detect{|handler| handler.match?(exception)} raise ::StateFlow::RecoverableException.new(recover_handler, exception) else context.log_with_stack_trace(:error, "NOT RECOVERED", :exception => exception, :backtrace => true, :exception_handlers => handlers, :recover_handler => recover_handler) raise exception end end end |