Sha256: ad6c5a496c079589239995ede40c6afbe7a2e22e25b09436bf10cf7bef99b981

Contents?: true

Size: 924 Bytes

Versions: 6

Compression:

Stored size: 924 Bytes

Contents

module Ratchetio
  module Rails
    module Middleware
      module ExceptionCatcher
        def self.included(base)
          base.send(:alias_method_chain, :render_exception, :ratchetio)
        end

        def render_exception_with_ratchetio(env, exception)
          # wrap everything in a begin-rescue block
          begin
            controller = env['action_controller.instance']
            request_data = controller.try(:ratchetio_request_data)
            person_data = controller.try(:ratchetio_person_data)
            Ratchetio.report_exception(exception, request_data, person_data)
          rescue Exception => exc
            # TODO use logger here?
            puts "[Ratchet.io] Exception while reporting exception to Ratchet.io: " 
            puts exc
          end

          # now continue as normal
          render_exception_without_ratchetio(env, exception)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ratchetio-0.4.2 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.4.1 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.4.0 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.3.2 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.3.1 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.3.0 lib/ratchetio/rails/middleware/exception_catcher.rb