Sha256: 27ea39bcbff80f9b09efddf37b155a46f4b723f61533531761120c8fc01c05e8

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

require 'runtimeerror_notifier/notifier'
require 'runtimeerror_notifier/tracker'
require 'runtimeerror_notifier/railtie' if defined?(Rails::Railtie)
require 'runtimeerror_notifier/sidekiq' if defined?(Sidekiq)
require 'runtimeerror_notifier/delayed_job' if defined?(Delayed) && defined?(Delayed::Worker)

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.27 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.26 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.25 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.24 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.23 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.22 lib/runtimeerror_notifier.rb
runtimeerror_notifier-0.0.21 lib/runtimeerror_notifier.rb