Sha256: 05a15778108a11ab56a4b954bbac66aee9d06fe1f7e77dc9b87d1ff193c35d04

Contents?: true

Size: 859 Bytes

Versions: 8

Compression:

Stored size: 859 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)
            Ratchetio.report_request_exception(env, exception, request_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

8 entries across 8 versions & 1 rubygems

Version Path
ratchetio-0.1.2 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.1.1 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.1.0 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.0.5 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.0.4 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.0.3 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.0.2 lib/ratchetio/rails/middleware/exception_catcher.rb
ratchetio-0.0.1 lib/ratchetio/rails/middleware/exception_catcher.rb