Sha256: 75e50b2194ced8e69f8cf5ce9c6118b750d77ce48f3649d601e62a2d1438c663

Contents?: true

Size: 1.34 KB

Versions: 11

Compression:

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

      ##
      # @param [Exception] exception
      # @return [Airbrake::Notice] the notice with information from the Rack env
      def build_notice(exception)
        Airbrake::Rack::NoticeBuilder.new(request.env).build_notice(exception)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
dfg-airbrake-5.6.2 lib/airbrake/rails/action_controller.rb
airbrake-5.6.1 lib/airbrake/rails/action_controller.rb
airbrake-5.6.0 lib/airbrake/rails/action_controller.rb
airbrake-5.5.0 lib/airbrake/rails/action_controller.rb
airbrake-5.4.5 lib/airbrake/rails/action_controller.rb
airbrake-5.4.4 lib/airbrake/rails/action_controller.rb
airbrake-5.4.3 lib/airbrake/rails/action_controller.rb
airbrake-5.4.2 lib/airbrake/rails/action_controller.rb
airbrake-5.4.1 lib/airbrake/rails/action_controller.rb
airbrake-5.4.0 lib/airbrake/rails/action_controller.rb
airbrake-5.3.0 lib/airbrake/rails/action_controller.rb