Module: RuntimeerrorNotifier

Defined in:
lib/runtimeerror_notifier.rb,
lib/runtimeerror_notifier/railtie.rb,
lib/runtimeerror_notifier/sidekiq.rb,
lib/runtimeerror_notifier/tracker.rb,
lib/runtimeerror_notifier/notifier.rb,
lib/runtimeerror_notifier/rake_handler.rb,
lib/generators/runtimeerror_notifier/install_generator.rb

Defined Under Namespace

Modules: RakeHandler Classes: InstallGenerator, Notifier, Railtie, Sidekiq, Tracker

Class Method Summary collapse

Class Method Details

.for(*emails) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/runtimeerror_notifier.rb', line 8

def self.for(*emails)
  RuntimeerrorNotifier::Notifier.for(*emails)
  if defined?(::Rails)
    ::Rails.application.config.middleware.insert 0, RuntimeerrorNotifier::Tracker
  end

  renderer_class = if defined?(::ActionDispatch::DebugExceptions)
    ::ActionDispatch::DebugExceptions
  elsif defined?(::ActionDispatch::ShowExceptions)
    ::ActionDispatch::ShowExceptions
  end

  if renderer_class
    renderer_class.class_eval do
      def render_exception_with_runtimeerror_notifier(env, exception)
        begin
          RuntimeerrorNotifier::Notifier.notification(env, exception, {})
        rescue Exception
          # do nothing
        end
        render_exception_without_runtimeerror_notifier(env, exception)
      end
      alias_method_chain :render_exception, :runtimeerror_notifier
    end
  end
end