Class: StateFlow::ExceptionHandler
- Defined in:
- lib/state_flow/exception_handler.rb
Instance Attribute Summary collapse
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#logging_error ⇒ Object
readonly
Returns the value of attribute logging_error.
-
#raise_error_in_handling ⇒ Object
readonly
Returns the value of attribute raise_error_in_handling.
-
#recovering ⇒ Object
readonly
Returns the value of attribute recovering.
-
#rolling_back ⇒ Object
readonly
Returns the value of attribute rolling_back.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(origin, *exceptions, &block) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
- #match?(exception) ⇒ Boolean
- #process(context) ⇒ Object
Methods included from ExceptionHandlerClient
#exception_handlers, #exception_handling
Methods included from ActionClient
Methods included from GuardClient
#guard, #guard_else, #guard_for, #guards
Methods inherited from Element
#flow, #inspect, #retry_in_recovering, #state, #to, uninspected_var, uninspected_vars, #update_to_destination
Methods included from ElementVisitable
Constructor Details
#initialize(origin, *exceptions, &block) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/state_flow/exception_handler.rb', line 9 def initialize(origin, *exceptions, &block) = exceptions. @exceptions = exceptions super(origin, &block) @recovering = [:recovering] || false @rolling_back = [:rolling_back] || [:rollback] || false @logging_error = [:logging] # 例外をハンドリングしている最中にエラーが出た場合にraiseするかどうか。デフォルトnil @raise_error_in_handling = [:raise_error_in_handling] end |
Instance Attribute Details
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
6 7 8 |
# File 'lib/state_flow/exception_handler.rb', line 6 def exceptions @exceptions end |
#logging_error ⇒ Object (readonly)
Returns the value of attribute logging_error.
7 8 9 |
# File 'lib/state_flow/exception_handler.rb', line 7 def logging_error @logging_error end |
#raise_error_in_handling ⇒ Object (readonly)
Returns the value of attribute raise_error_in_handling.
7 8 9 |
# File 'lib/state_flow/exception_handler.rb', line 7 def raise_error_in_handling @raise_error_in_handling end |
#recovering ⇒ Object (readonly)
Returns the value of attribute recovering.
7 8 9 |
# File 'lib/state_flow/exception_handler.rb', line 7 def recovering @recovering end |
#rolling_back ⇒ Object (readonly)
Returns the value of attribute rolling_back.
7 8 9 |
# File 'lib/state_flow/exception_handler.rb', line 7 def rolling_back @rolling_back end |
Instance Method Details
#match?(exception) ⇒ Boolean
20 21 22 23 |
# File 'lib/state_flow/exception_handler.rb', line 20 def match?(exception) prepare_exceptions exceptions.any?{|klass| exception.is_a?(klass)} end |
#process(context) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/state_flow/exception_handler.rb', line 25 def process(context) context.recovered_exceptions << context.exceptions.last if recovering context.record_reload_if_possible # rollbackよりもreloadが先じゃないとネストしたtransactionでおかしい場合がある? # context.transaction_rollback if rolling_back super end |