Sha256: 2fa38f3d1fe484624e040897896920d4ca8bd822ec6cab787f400cdceb0136e9

Contents?: true

Size: 1.47 KB

Versions: 21

Compression:

Stored size: 1.47 KB

Contents

module Airbrake
  module Rails
    # Contains helper methods that can be used inside Rails controllers to send
    # notices to Airbrake. The main benefit of using them instead of the direct
    # API is that they automatically add information from the Rack environment
    # to notices.
    module ActionController
      private

      # A helper method for sending notices to Airbrake *asynchronously*.
      # Attaches information from the Rack env.
      # @see Airbrake#notify, #notify_airbrake_sync
      def notify_airbrake(exception, params = {}, notifier_name = :default)
        return unless (notice = build_notice(exception, params, notifier_name))
        Airbrake[notifier_name].notify(notice, params)
      end

      # A helper method for sending notices to Airbrake *synchronously*.
      # Attaches information from the Rack env.
      # @see Airbrake#notify_sync, #notify_airbrake
      def notify_airbrake_sync(exception, params = {}, notifier_name = :default)
        return unless (notice = build_notice(exception, params, notifier_name))
        Airbrake[notifier_name].notify_sync(notice, params)
      end

      # @param [Exception] exception
      # @return [Airbrake::Notice] the notice with information from the Rack env
      def build_notice(exception, params = {}, notifier_name = :default)
        return unless (notice = Airbrake[notifier_name].build_notice(exception, params))
        notice.stash[:rack_request] = request
        notice
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
airbrake-8.1.4 lib/airbrake/rails/action_controller.rb
airbrake-8.1.3 lib/airbrake/rails/action_controller.rb
airbrake-8.1.2 lib/airbrake/rails/action_controller.rb
airbrake-8.1.1 lib/airbrake/rails/action_controller.rb
airbrake-8.1.0 lib/airbrake/rails/action_controller.rb
airbrake-8.0.1 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0.rc.9 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0.rc.8 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0.rc.7 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0.rc.6 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0.rc.5 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0.rc.3 lib/airbrake/rails/action_controller.rb
airbrake-8.0.0.rc.2 lib/airbrake/rails/action_controller.rb
airbrake-7.5.0.pre.1 lib/airbrake/rails/action_controller.rb
airbrake-7.4.0 lib/airbrake/rails/action_controller.rb
airbrake-7.3.5 lib/airbrake/rails/action_controller.rb
airbrake-7.3.4 lib/airbrake/rails/action_controller.rb
airbrake-7.3.3 lib/airbrake/rails/action_controller.rb
airbrake-7.3.2 lib/airbrake/rails/action_controller.rb