我收到以下错误:
MailingJob failed with NameError: uninitialized constant MailingJob::MissingInfo - 2 failed attempts
我的代码:
class MailingJob < Struct.new(:mailing_id)
def perform
begin
@message_reply = ....
raise MissingInfo, "Message reply not found" if @message_reply.length == 0
.....
rescue MissingInfo => detail
Rails.logger.info "RESCUED - MissingInfo,RESCUED - MissingInfo, RESCUED - MissingInfo, RESCUED - MissingInfo, RESCUED - MissingInfo"
Rails.logger.info detail
end
end
这是我第一次使用开始/救援,建议,帮助?感谢
答案 0 :(得分:1)
您正在尝试使用未定义的常量。您必须定义异常类:
class MissingInfo < StandardError; end
其次,我不会依赖日志来捕获错误。相反,我会使用诸如Hoptoad之类的服务。