Sha256: 6cb873993ef42688481302c2b12c53e519c25bb54c6861f2affe450934d5cda5

Contents?: true

Size: 1.2 KB

Versions: 47

Compression:

Stored size: 1.2 KB

Contents

module Airbrake
  module Rails
    # Rails <4.2 has a bug with regard to swallowing exceptions in the
    # +after_commit+ and the +after_rollback+ hooks: it doesn't bubble up
    # exceptions from there.
    #
    # This module makes it possible to report exceptions occurring there.
    #
    # @see https://github.com/rails/rails/pull/14488 Detailed description of the
    #   bug and the fix
    # @see https://goo.gl/348lor Rails 4.2+ implementation (fixed)
    # @see https://goo.gl/ddFNg7 Rails <4.2 implementation (bugged)
    module ActiveRecord
      # Patches default +run_callbacks+ with our version, which is capable of
      # notifying about exceptions.
      #
      # rubocop:disable Lint/RescueException
      def run_callbacks(kind, *args, &block)
        # Let the post process handle the exception if it's not a bugged hook.
        return super unless %i[commit rollback].include?(kind)

        # Handle the exception ourselves. The 'ex' exception won't be
        # propagated, therefore we must notify it here.
        begin
          super
        rescue Exception => ex
          Airbrake.notify(ex)
          raise ex
        end
      end
      # rubocop:enable Lint/RescueException
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
airbrake-10.0.0 lib/airbrake/rails/active_record.rb
airbrake-9.5.5 lib/airbrake/rails/active_record.rb
airbrake-9.5.4 lib/airbrake/rails/active_record.rb
airbrake-9.5.3 lib/airbrake/rails/active_record.rb
airbrake-9.5.2 lib/airbrake/rails/active_record.rb
airbrake-9.5.1 lib/airbrake/rails/active_record.rb
airbrake-9.5.0 lib/airbrake/rails/active_record.rb
airbrake-9.4.5 lib/airbrake/rails/active_record.rb
airbrake-9.4.4 lib/airbrake/rails/active_record.rb
airbrake-9.4.3 lib/airbrake/rails/active_record.rb
airbrake-9.4.2 lib/airbrake/rails/active_record.rb
airbrake-9.4.1 lib/airbrake/rails/active_record.rb
airbrake-9.4.0 lib/airbrake/rails/active_record.rb
airbrake-9.3.0 lib/airbrake/rails/active_record.rb
airbrake-9.2.2 lib/airbrake/rails/active_record.rb
airbrake-9.2.1 lib/airbrake/rails/active_record.rb
airbrake-9.2.0 lib/airbrake/rails/active_record.rb
airbrake-9.1.0 lib/airbrake/rails/active_record.rb
airbrake-9.0.2 lib/airbrake/rails/active_record.rb
airbrake-9.0.1 lib/airbrake/rails/active_record.rb