我们在整个代码库中使用空气制动,除了不从Rails层次结构(即ActiveRecord)继承的自定义类外,它工作得很好。
一些代码:
class Offer
def counter(amount, qty=1)
begin
offers_response = viyet_mage_rest_client.counter_offer(@id.to_i, amount, qty.to_i)
rescue => e
notify_airbrake(e)
offers_response = []
end
end
end在空气制动器中我们看到:
NoMethodError: undefined method `notify_airbrake' for Offer:Class作为错误。我要的是实际的错误,而不是报告错误的错误!
我们的airbrake.rb文件:
if Rails.env.production? || Rails.env.staging?
Airbrake.configure do |config|
config.api_key = Settings.airbrake.api_key
config.secure = true
end
end任何帮助都将不胜感激!
发布于 2015-09-11 16:25:17
您需要的方法是Airbrake.notify_or_ignore()。对于您所举的例子:
class Offer
def counter(amount, qty=1)
begin
offers_response = viyet_mage_rest_client.counter_offer(@id.to_i, amount, qty.to_i)
rescue => e
Airbrake.notify_or_ignore(e)
offers_response = []
end
end
end更多细节可以在这里找到:https://github.com/airbrake/airbrake/wiki/Using-Airbrake-with-plain-Ruby
https://stackoverflow.com/questions/32527848
复制相似问题