lib/sentry/rails/railtie.rb in sentry-rails-4.1.1 vs lib/sentry/rails/railtie.rb in sentry-rails-4.1.2

- old
+ new

@@ -1,27 +1,30 @@ require "rails" require "sentry/rails/capture_exceptions" +require "sentry/rails/rescued_exception_interceptor" require "sentry/rails/backtrace_cleaner" require "sentry/rails/controller_methods" require "sentry/rails/controller_transaction" require "sentry/rails/active_job" require "sentry/rails/overrides/streaming_reporter" module Sentry class Railtie < ::Rails::Railtie # middlewares can't be injected after initialize initializer "sentry.use_rack_middleware" do |app| + # need to be placed at first to capture as many errors as possible app.config.middleware.insert 0, Sentry::Rails::CaptureExceptions + # need to be placed at last to smuggle app exceptions via env + app.config.middleware.use(Sentry::Rails::RescuedExceptionInterceptor) end config.after_initialize do next unless Sentry.initialized? configure_sentry_logger extend_controller_methods extend_active_job - override_exceptions_handling override_streaming_reporter setup_backtrace_cleanup_callback inject_breadcrumbs_logger activate_tracing end @@ -52,22 +55,9 @@ def setup_backtrace_cleanup_callback backtrace_cleaner = Sentry::Rails::BacktraceCleaner.new Sentry.configuration.backtrace_cleanup_callback = lambda do |backtrace| backtrace_cleaner.clean(backtrace) - end - end - - def override_exceptions_handling - if Sentry.configuration.rails.report_rescued_exceptions - require 'sentry/rails/overrides/debug_exceptions_catcher' - if defined?(::ActionDispatch::DebugExceptions) - exceptions_class = ::ActionDispatch::DebugExceptions - elsif defined?(::ActionDispatch::ShowExceptions) - exceptions_class = ::ActionDispatch::ShowExceptions - end - - exceptions_class.send(:prepend, Sentry::Rails::Overrides::DebugExceptionsCatcher) end end def override_streaming_reporter ActiveSupport.on_load :action_view do