救援500错误,没有搞乱Airbrake

bev*_*anb 6 ruby-on-rails airbrake

我的Rails应用程序上安装了Airbrake.但是,我还希望在500发生时执行一些其他操作.如何在不干扰Airbrake的情况下挽救500个错误?

dee*_*our 9

你可以在你做的一个方法ApplicationController,你可以把

unless Rails.application.config.consider_all_requests_local
  rescue_from Exception, with: :render_500
end
Run Code Online (Sandbox Code Playgroud)

后来,一种新render_500方法

def render_500(ex)
  notify_airbrake(ex)
  # render your template/message
end
Run Code Online (Sandbox Code Playgroud)