Sha256: 1602c2c40586840f413236b6be2f089a026d6ff9028c892f383278444ee8e169

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 KB

Contents

module Jets
  module ExceptionReporting
    extend ActiveSupport::Concern

    delegate :with_exception_reporting, to: :class
    module ClassMethods
      def with_exception_reporting
        yield
      rescue => exception
        Jets.report_exception(exception)
        decorate_with_exception_reported(exception)
        raise
      end

      # We decorate the exception with a with_exception_reported? method so we
      # can use it the MainProcessor rescue Exception handling to not
      # double report the exception and only reraise.
      #
      # If we have properly rescue all exceptions then this would not be needed.
      # However, we're being paranoid also by rescuing Exception in the MainProcessor.
      #
      # Also, in general, it's hard to follow Exception bubbling logic. This
      # approach allows us to not have to worry about bubbling and call
      # with_exception_reporting indiscriminately.
      def decorate_with_exception_reported(exception)
        unless exception.respond_to?(:with_exception_reported?)
          exception.define_singleton_method(:with_exception_reported?) { true }
        end
      end
    end

    module Process
      extend ActiveSupport::Concern
      module ClassMethods
        def process(event, context, meth)
          with_exception_reporting do
            super
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
jets-6.0.5 lib/jets/exception_reporting.rb
jets-6.0.4 lib/jets/exception_reporting.rb
jets-6.0.3 lib/jets/exception_reporting.rb
jets-6.0.2 lib/jets/exception_reporting.rb
jets-5.0.13 lib/jets/exception_reporting.rb
jets-5.0.12 lib/jets/exception_reporting.rb
jets-5.0.11 lib/jets/exception_reporting.rb
jets-5.0.10 lib/jets/exception_reporting.rb
jets-5.0.9 lib/jets/exception_reporting.rb
jets-5.0.8 lib/jets/exception_reporting.rb
jets-5.0.7 lib/jets/exception_reporting.rb
jets-5.0.6 lib/jets/exception_reporting.rb
jets-5.0.5 lib/jets/exception_reporting.rb
jets-5.0.4 lib/jets/exception_reporting.rb
jets-5.0.3 lib/jets/exception_reporting.rb
jets-5.0.2 lib/jets/exception_reporting.rb
jets-5.0.1 lib/jets/exception_reporting.rb
jets-5.0.0 lib/jets/exception_reporting.rb
jets-5.0.0.beta1 lib/jets/exception_reporting.rb