【发布时间】:2018-11-11 07:08:20
【问题描述】:
我编写了以下代码来处理我的异常。
class Business < ExceptionController
def work(arg1,arg2)
#####some business logic that cause exception
end
end
class ExceptionController < ApplicationController
rescue_from Exception, :with => :render_error_response
def render_error_response(e)
p e.message
p e.backtrace
end
end
我在异常控制器中定义的render_error_response 中记录消息和回溯。我想打印导致异常的函数的参数,即 arg1、arg2 的 work 函数。
除了异常回溯,我还需要调用 def work 的对象信息。
【问题讨论】:
-
你最好先让你的代码在语法上有效。
标签: ruby exception-handling ruby-on-rails-3.2