Sha256: 97d457c9da292a62401b97fd467ca9e9254506c02a692f48524f7dd03a049075

Contents?: true

Size: 939 Bytes

Versions: 10

Compression:

Stored size: 939 Bytes

Contents

module ActiveTracker
  class ExceptionCapturer
    def initialize(app)
      @app = app
    end

    def call(env)

      response = @app.call(env)

      framework_exception = env['action_dispatch.exception']
      if framework_exception
        record_exception(env, framework_exception)
      end

      response
    rescue Exception => exception

      record_exception(env, exception)
      raise exception
    end

    def record_exception(env, exception)
      if env['action_dispatch.backtrace_cleaner']
        backtrace = env['action_dispatch.backtrace_cleaner'].filter(exception.backtrace)
        backtrace = exception.backtrace if backtrace.blank?
      else
        backtrace = exception.backtrace
      end
      class_name = exception.class.name
      message = exception.message
      backtrace = backtrace || []

      ActiveTracker::Plugin::Exception.exception_capture(class_name, message, backtrace)
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activetracker-0.4.9 lib/active_tracker/exception_capturer.rb
activetracker-0.4.8 lib/active_tracker/exception_capturer.rb
activetracker-0.4.7 lib/active_tracker/exception_capturer.rb
activetracker-0.4.6 lib/active_tracker/exception_capturer.rb
activetracker-0.4.5 lib/active_tracker/exception_capturer.rb
activetracker-0.4.4 lib/active_tracker/exception_capturer.rb
activetracker-0.4.3 lib/active_tracker/exception_capturer.rb
activetracker-0.4.2 lib/active_tracker/exception_capturer.rb
activetracker-0.4.1 lib/active_tracker/exception_capturer.rb
activetracker-0.4.0 lib/active_tracker/exception_capturer.rb