Sha256: 914d4d2a3eee5d184e9062d203eb17575a1d35d57495e0365ba5bd7b148f50e8

Contents?: true

Size: 922 Bytes

Versions: 10

Compression:

Stored size: 922 Bytes

Contents

module Sentry
  module Rails
    class RescuedExceptionInterceptor
      def initialize(app)
        @app = app
      end

      def call(env)
        return @app.call(env) unless Sentry.initialized?

        begin
          @app.call(env)
        rescue => e
          request = ActionDispatch::Request.new(env)

          # Rails' ShowExceptions#render_exception will mutate env for the exceptions app
          # so we need to hold a copy of env to report the accurate data (like request's url)
          if request.show_exceptions?
            scope = Sentry.get_current_scope
            copied_env = scope.rack_env.dup
            copied_env["sentry.original_transaction"] = scope.transaction_name
            scope.set_rack_env(copied_env)
          end

          env["sentry.rescued_exception"] = e if Sentry.configuration.rails.report_rescued_exceptions
          raise e
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sentry-rails-4.3.4 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.3.3 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.3.3.pre.beta.0 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.3.2 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.3.1 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.3.0 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.2.2 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.2.1 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.2.0 lib/sentry/rails/rescued_exception_interceptor.rb
sentry-rails-4.1.7 lib/sentry/rails/rescued_exception_interceptor.rb