小编Ara*_*.ck的帖子

Ruby中的SystemStackError使用Aquarium进行异常处理(面向方面​​编程)

我正在尝试使用Ruby中的AOP处理异常.我在这里使用的工具包是Aquarium(http://aquarium.rubyforge.org/).

我编写了一个示例代码,它将尝试映射所写的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
Run Code Online (Sandbox Code Playgroud)

ruby aop exception-handling

6
推荐指数
1
解决办法
254
查看次数

标签 统计

aop ×1

exception-handling ×1

ruby ×1