Sha256: 84b3ef2bab8c8b063d8fc705b636a06d1aaae8715b3e2f739279b4ae84578365

Contents?: true

Size: 1.34 KB

Versions: 19

Compression:

Stored size: 1.34 KB

Contents

require 'better_errors'

module BetterErrors
  class Middleware
    alias_method :orig_show_error_page, :show_error_page

    private

    def show_error_page(*args)
      exception = @error_page.exception

      env = args.first
      exception_data = nil
      begin
        controller = env['action_controller.instance']
        request_data = controller.rollbar_request_data rescue nil
        person_data = controller.rollbar_person_data rescue nil
        exception_data = Rollbar.scope(:request => request_data, :person => person_data).error(exception, :use_exception_level_filters => true)
      rescue => e
        Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e}"
      end

      # if an exception was reported, save uuid in the env
      # so it can be displayed to the user on the error page
      if exception_data.is_a?(Hash)
        env['rollbar.exception_uuid'] = exception_data[:uuid]
        Rollbar.log_info "[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
      elsif exception_data == 'disabled'
        Rollbar.log_info "[Rollbar] Exception not reported because Rollbar is disabled"
      elsif exception_data == 'ignored'
        Rollbar.log_info "[Rollbar] Exception not reported because it was ignored"
      end

      # now continue as normal
      orig_show_error_page(*args)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rollbar-2.3.0 lib/rollbar/better_errors.rb
rollbar-2.2.1 lib/rollbar/better_errors.rb
rollbar-2.2.0 lib/rollbar/better_errors.rb
rollbar-2.1.2 lib/rollbar/better_errors.rb
rollbar-2.1.1 lib/rollbar/better_errors.rb
rollbar-2.1.0 lib/rollbar/better_errors.rb
rollbar-2.0.2 lib/rollbar/better_errors.rb
rollbar-2.0.1 lib/rollbar/better_errors.rb
rollbar-2.0.0 lib/rollbar/better_errors.rb
rollbar-1.5.3 lib/rollbar/better_errors.rb
rollbar-1.5.2 lib/rollbar/better_errors.rb
rollbar-1.5.1 lib/rollbar/better_errors.rb
rollbar-1.5.0 lib/rollbar/better_errors.rb
rollbar-1.4.5 lib/rollbar/better_errors.rb
rollbar-1.4.4 lib/rollbar/better_errors.rb
rollbar-1.4.3 lib/rollbar/better_errors.rb
rollbar-1.4.2 lib/rollbar/better_errors.rb
rollbar-1.4.1 lib/rollbar/better_errors.rb
rollbar-1.4.0 lib/rollbar/better_errors.rb