Sha256: 57413e79d59bac9d24ba962f1c8a2f7b25664fcdf6678da84885ad63dfd99487

Contents?: true

Size: 1.14 KB

Versions: 33

Compression:

Stored size: 1.14 KB

Contents

module Rollbar
  module ExceptionReporter
    include RequestDataExtractor

    def report_exception_to_rollbar(env, exception)
      rollbar_debug "[Rollbar] Reporting exception: #{exception.try(:message)}", :error
      request_data = extract_request_data_from_rack(env)
      person_data = extract_person_data_from_controller(env)
      exception_data = Rollbar.report_exception(exception, request_data, person_data)
      
      if exception_data.is_a?(Hash)
        env['rollbar.exception_uuid'] = exception_data[:uuid]
        rollbar_debug "[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
      elsif exception_data == 'disabled'
        rollbar_debug "[Rollbar] Exception not reported because Rollbar is disabled"
      elsif exception_data == 'ignored'
        rollbar_debug "[Rollbar] Exception not reported because it was ignored"
      end
    rescue => e
      rollbar_debug "[Rollbar] Exception while reporting exception to Rollbar: #{e.try(:message)}"
    end

    def rollbar_debug(message, level = :debug)
      if defined?(Rails)
        ::Rails.logger.send(level, message)
      else
        puts message
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
rollbar-0.11.3 lib/rollbar/exception_reporter.rb
rollbar-0.11.2 lib/rollbar/exception_reporter.rb
rollbar-0.11.1 lib/rollbar/exception_reporter.rb
rollbar-0.10.14 lib/rollbar/exception_reporter.rb
rollbar-0.10.12 lib/rollbar/exception_reporter.rb
rollbar-0.10.11 lib/rollbar/exception_reporter.rb
rollbar-0.10.10 lib/rollbar/exception_reporter.rb
rollbar-0.10.9 lib/rollbar/exception_reporter.rb
rollbar-0.10.8 lib/rollbar/exception_reporter.rb
rollbar-0.10.7 lib/rollbar/exception_reporter.rb
rollbar-0.10.6 lib/rollbar/exception_reporter.rb
rollbar-0.10.5 lib/rollbar/exception_reporter.rb
rollbar-0.10.4 lib/rollbar/exception_reporter.rb