Class: Aquarium::Aspects::AfterRaisingAdviceChainNode

Inherits:
AdviceChainNode show all
Includes:
Utils::ArrayUtils
Defined in:
lib/aquarium/aspects/advice.rb

Overview

Note that the advice is not invoked if the exception is not of a type specified when the advice was created. However, the default is to advise all thrown objects.

Constant Summary

Constants inherited from AdviceChainNode

Aquarium::Aspects::AdviceChainNode::NIL_OBJECT

Instance Method Summary collapse

Methods included from Utils::ArrayUtils

#make_array, make_array, #strip_array_nils, strip_array_nils

Methods inherited from AdviceChainNode

#call, #call_advice, #each, #empty?, #invoke_original_join_point, #last, #size

Constructor Details

#initialize(options = {}) ⇒ AfterRaisingAdviceChainNode

Returns a new instance of AfterRaisingAdviceChainNode.



200
201
202
# File 'lib/aquarium/aspects/advice.rb', line 200

def initialize options = {}
  super options
end

Instance Method Details

#advice_wrapper(jp) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/aquarium/aspects/advice.rb', line 203

def advice_wrapper jp
  begin
    next_node.call jp
  rescue Object => raised_exception
    if after_raising_exceptions_list_includes raised_exception
      update_current_context jp
      jp.context.advice_kind = :after_raising
      jp.context.raised_exception = raised_exception
      call_advice jp
      raised_exception = jp.context.raised_exception   # allow advice to modify the raised exception
      reset_current_context jp
    end
    raise raised_exception
  end
end