Jua*_*nra 1 exception-handling ruby-on-rails rack-middleware exception-notification
我第一次尝试使用exception_notification.我观看了Railscast并遵循了作者在http://smartinez87.github.io/exception_notification/中的说明.一切似乎在某些例外情况下工作正常,但与其他情况不同.
我测试和错误,如收到的电子邮件错误notificatios从我的开发环境"An ActionView::Template::Error occurred in static_pages#home:
."不过,也有一些例外,如RoutingException
和RecordNotFound
那些不被逮住ExceptionNotification,我不知道为什么,因为我没有任何rescue_from策略我的application_controller中的任何一种.
我正在使用rails 3.2.12并检查中间件堆栈数组,我可以看到ExceptionNotification只是最后一个,并且似乎某种异常不会在堆栈中出现,所以Exception Notification不知道他们.
所以,问题是:我做错了什么? ExceptionNotification 之间有什么区别ActionController::RoutingError
或者ActiveRecord::RecordNotFound
哪些不被捕获,ActionView::Template::Error
哪些被捕获并导致异常通知将通知电子邮件发送到我的收件箱.
提前致谢
这些异常类型将被忽略,作为该gem的默认配置的一部分.请参见此处的第25行:https://github.com/smartinez87/exception_notification/blob/master/lib/exception_notifier.rb,其中包含:
@@ignored_exceptions = %w{ActiveRecord::RecordNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat}
Run Code Online (Sandbox Code Playgroud)
您可以在环境文件中重写此行为(即development.rb等).
通知所有错误的示例:
config.middleware.use ExceptionNotifier,
ignore_exceptions: []
Run Code Online (Sandbox Code Playgroud)
将RuntimeError添加到默认忽略列表的示例:
config.middleware.use ExceptionNotifier,
ignore_exceptions: ExceptionNotifier.default_ignore_exceptions + [RuntimeError]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
888 次 |
最近记录: |