RubyでAOPを使用して例外を処理しようとしています。ここで使用したツールキットはAquarium(http://aquarium.rubyforge.org/)です。RubyでのSystemStackError Aquarium(Aspect Oriented Programming)を使用した例外処理。
書き留めたApplicationControllerクラスのすべての子孫(サブクラス)をマップしようとするサンプルコードを作成しました。
次のプログラムを実行すると、SystemStackErrorが発生します(スタック制限を "ulimit -s"を使用して設定しようとしました)。誰かがこれで私を助けてください!またはマッピングの提案:スーパークラスのサブクラスのall_methodsは歓迎されています..事前に感謝します。
require 'aquarium'
include Aquarium::Aspects
class ApplicationController
end
class Abc < ApplicationController
def func
puts "func called"
raise Exception.new # SystemStackError is thrown before reaching place
end
end
#Dummy class
class Def < ApplicationController
end
Aspect.new :after_raising => Exception,
:in_types_and_descendents => "ApplicationController" do |jp, object, *args|
puts "Exception Handling Code"
end
a = Abc.new
a.func
を見つけることができます。 –
いいえ、それでも動作しません! –
多分あなたはhttp://apidock.com/rails/ActiveSupport/Rescuable/ClassMethods/rescue_fromのようなものを使うことができますか? – Fivell