class Airbrake::Rack::NoticeBuilder

A helper class for filling notices with all sorts of useful information coming from the Rack environment.

Constants

HTTP_HEADER_PREFIXES

@return [Array<String>] the prefixes of the majority of HTTP headers in

Rack (some prefixes match the header names for simplicity)

Attributes

builders[R]

@return [Array<Proc>] the list of notice builders

Public Class Methods

add_builder(&block) click to toggle source

Adds user defined builders to the chain.

# File lib/airbrake/rack/notice_builder.rb, line 16
def add_builder(&block)
  @builders << block
end
new(rack_env, notifier_name = :default) click to toggle source

@param [Hash{String=>Object}] rack_env The Rack environment

# File lib/airbrake/rack/notice_builder.rb, line 32
def initialize(rack_env, notifier_name = :default)
  @rack_env = rack_env
  @notifier_name = notifier_name
  @request = ::Rack::Request.new(rack_env)
end

Public Instance Methods

build_notice(exception) click to toggle source

Adds context, session, params and other fields based on the Rack env.

@param [Exception] exception @return [Airbrake::Notice] the notice with extra information

# File lib/airbrake/rack/notice_builder.rb, line 43
def build_notice(exception)
  return unless (notice = Airbrake.build_notice(exception, {}, @notifier_name))

  NoticeBuilder.builders.each { |builder| builder.call(notice, @request) }
  notice
end
unknown() click to toggle source

Adds context (URL, User-Agent, framework version, controller and more).

# File lib/airbrake/rack/notice_builder.rb, line 52
add_builder do |notice, request|
  context = notice[:context]