我有以下内容:
class MailingJob < Struct.new(:mailing_id)
class MissingInfo < ArgumentError; end
def perform
....
begin
......
raise MissingInfo, "Not found", message_all, @message_from if @message_reply.length == 0
......
rescue MissingInfo => reason, message_all, message_from
UserMailer.delay.incoming_mails_error_notification(reason, message_all, message_from)
end
end
我在这里遇到的问题是,在我的恢复中,我需要访问开始块中的几个变量,所以当我调用 RAISE 时我试图传递它们。这似乎不起作用。此外,这些变量在许多加注中是一致的,因此它确实填满了页面。
有没有办法让这些变量在resuce中访问而不必在raise中定义它们?
如果没有,我如何使用 raise 将它们传递给救援?上述错误与:
SyntaxError (/Users/xxxxx/Sites/xxxxxxx/lib/mailing_job.rb:117: syntax error, unexpected ',', expecting kTHEN or ':' or '\n' or ';'
rescue MissingInfo => reason, message_all, message_from
^
谢谢!