Sha256: e0629e6b1e0e98abf729089ebf6119bf90c6395595e2a87976fd8fffdab52f44

Contents?: true

Size: 1.26 KB

Versions: 24

Compression:

Stored size: 1.26 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.try(:rollbar_request_data)
        person_data = controller.try(:rollbar_person_data)
        exception_data = Rollbar.report_exception(exception, request_data, person_data)
      rescue => e
        # TODO use logger here?
        puts "[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]
        puts "[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
      elsif exception_data == 'disabled'
        puts "[Rollbar] Exception not reported because Rollbar is disabled"
      elsif exception_data == 'ignored'
        puts "[Rollbar] Exception not reported because it was ignored"
      end

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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rollbar-0.12.15 lib/rollbar/better_errors.rb
rollbar-0.12.14 lib/rollbar/better_errors.rb
rollbar-0.12.13 lib/rollbar/better_errors.rb
rollbar-0.12.12 lib/rollbar/better_errors.rb
rollbar-0.12.11 lib/rollbar/better_errors.rb
rollbar-0.12.10 lib/rollbar/better_errors.rb
rollbar-0.12.9 lib/rollbar/better_errors.rb
rollbar-0.12.8 lib/rollbar/better_errors.rb
rollbar-0.12.7 lib/rollbar/better_errors.rb
rollbar-0.12.6 lib/rollbar/better_errors.rb
rollbar-0.12.5 lib/rollbar/better_errors.rb
rollbar-0.12.3 lib/rollbar/better_errors.rb
rollbar-0.12.2 lib/rollbar/better_errors.rb
rollbar-0.12.1 lib/rollbar/better_errors.rb
rollbar-0.12.0 lib/rollbar/better_errors.rb
rollbar-0.11.8 lib/rollbar/better_errors.rb
rollbar-0.11.7 lib/rollbar/better_errors.rb
rollbar-0.11.6 lib/rollbar/better_errors.rb
rollbar-0.11.5 lib/rollbar/better_errors.rb
rollbar-0.11.4 lib/rollbar/better_errors.rb