Sha256: 570db3fb5c0ae2388c7a038699d0d6d55946839a1fab1fa43b28c5f7c190e240

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 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 = :default)
        return unless (notice = build_notice(exception, params, notifier))
        Airbrake.notify(notice, params, notifier)
      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 = :default)
        return unless (notice = build_notice(exception, params, notifier))
        Airbrake.notify_sync(notice, params, notifier)
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
airbrake-5.7.1 lib/airbrake/rails/action_controller.rb
airbrake-5.7.0 lib/airbrake/rails/action_controller.rb
airbrake-5.7.0.rc.1 lib/airbrake/rails/action_controller.rb