Sha256: 5124a203db2558dd04c56d0b3e0e8054d94412e9a811b6f1fce8dc01a8d85752

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require 'runtimeerror_notifier/notifier'
require 'runtimeerror_notifier/tracker'
require 'runtimeerror_notifier/railtie' if defined?(Rails::Railtie)

module RuntimeerrorNotifier
  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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
runtimeerror_notifier-0.0.19 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.18 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.17 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.15 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.14 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.13 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.12 lib/runtimeerror_notifier.rb