Sha256: b47a4bec731ffe0b96b7d985068770fb36e7032d3478a12e81b7e27d30e461ec

Contents?: true

Size: 1.28 KB

Versions: 25

Compression:

Stored size: 1.28 KB

Contents

module Rollbar
  module ExceptionReporter # :nodoc:
    def report_exception_to_rollbar(env, exception)
      return unless capture_uncaught?

      log_exception_message(exception)

      exception_data = exception_data(exception)

      if exception_data.is_a?(Hash)
        env['rollbar.exception_uuid'] = exception_data[:uuid]
        Rollbar.log_debug "[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
      elsif exception_data == 'disabled'
        Rollbar.log_debug '[Rollbar] Exception not reported because Rollbar is disabled'
      elsif exception_data == 'ignored'
        Rollbar.log_debug '[Rollbar] Exception not reported because it was ignored'
      end
    rescue StandardError => e
      Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e.message}"
    end

    def capture_uncaught?
      Rollbar.configuration.capture_uncaught != false
    end

    def log_exception_message(exception)
      exception_message = exception.respond_to?(:message) ? exception.message : 'No Exception Message'
      Rollbar.log_debug "[Rollbar] Reporting exception: #{exception_message}"
    end

    def exception_data(exception)
      Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception, :use_exception_level_filters => true)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
rollbar-3.2.0 lib/rollbar/exception_reporter.rb
rollbar-3.1.2 lib/rollbar/exception_reporter.rb
rollbar-3.1.1 lib/rollbar/exception_reporter.rb
rollbar-3.1.0 lib/rollbar/exception_reporter.rb
rollbar-3.0.1 lib/rollbar/exception_reporter.rb
rollbar-3.0.0 lib/rollbar/exception_reporter.rb
rollbar-2.27.1 lib/rollbar/exception_reporter.rb
rollbar-2.27.0 lib/rollbar/exception_reporter.rb
rollbar-2.26.1 lib/rollbar/exception_reporter.rb
rollbar-2.26.0 lib/rollbar/exception_reporter.rb
rollbar-2.25.1 lib/rollbar/exception_reporter.rb
rollbar-2.25.0 lib/rollbar/exception_reporter.rb
rollbar-2.24.0 lib/rollbar/exception_reporter.rb
rollbar-2.23.2 lib/rollbar/exception_reporter.rb
rollbar-2.23.1 lib/rollbar/exception_reporter.rb
rollbar-2.23.0 lib/rollbar/exception_reporter.rb
rollbar-2.22.1 lib/rollbar/exception_reporter.rb
rollbar-2.22.0 lib/rollbar/exception_reporter.rb
rollbar-2.21.0 lib/rollbar/exception_reporter.rb
rollbar-2.20.2 lib/rollbar/exception_reporter.rb