Sha256: c4aadd83c74113b68d68e029afc4eceaed4ba1020a0b0ffc11c2ada9ba53f5a0

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module Goalie
  class CustomErrorPages
    alias_method :orig_render_exception, :render_exception
    
    private

    def render_exception(env, exception)
      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.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_render_exception(env, exception)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rollbar-0.12.16 lib/rollbar/goalie.rb