Parent

Airbrake::Notice

Attributes

action[RW]

The action (if any) that was called in this request

api_key[RW]

The API key for the project to which this notice should be sent

backtrace[RW]

The backtrace from the given exception or hash.

backtrace_filters[RW]
cgi_data[RW]

CGI variables such as HTTP_METHOD

component[RW]

The component (if any) which was used in this request (usually the controller)

controller[R]

The component (if any) which was used in this request (usually the controller)

environment_name[RW]

The name of the server environment (such as "production")

error_class[RW]

The name of the class of error (such as RuntimeError)

error_message[RW]

The message from the exception, or a general description of the error

exception[RW]

The exception that caused this notice, if any

hostname[RW]

The host name where this error occurred (if any)

ignore[RW]
ignore_by_filters[RW]
notifier_name[RW]

The name of the notifier library sending this notice, such as "Airbrake Notifier"

notifier_url[RW]

A URL for more information about the notifier library sending this notice

notifier_version[RW]

The version number of the notifier library sending this notice, such as "2.1.3"

parameters[RW]

A hash of parameters from the query string or post body.

params[R]

A hash of parameters from the query string or post body.

params_filters[RW]
project_root[RW]

The path to the project that caused the error (usually Rails.root)

session_data[RW]

A hash of session data from the request

url[RW]

The URL at which the error occurred (if any)

user[RW]

Details about the user who experienced the error

Public Class Methods

attr_reader(*names) click to toggle source
Also aliased as: attr_reader_without_tracking
attr_reader_with_tracking(*names) click to toggle source
# File lib/airbrake/notice.rb, line 8
def attr_reader_with_tracking(*names)
  attr_readers.concat(names)
  attr_reader_without_tracking(*names)
end
Also aliased as: attr_reader
attr_reader_without_tracking(*names) click to toggle source
Alias for: attr_reader
attr_readers() click to toggle source
# File lib/airbrake/notice.rb, line 17
def attr_readers
  @attr_readers ||= []
end
new(args) click to toggle source
# File lib/airbrake/notice.rb, line 104
def initialize(args)
  self.args         = args
  self.exception    = args[:exception]
  self.api_key      = args[:api_key]
  self.project_root = args[:project_root]
  self.url          = args[:url] || rack_env(:url)

  self.notifier_name    = args[:notifier_name]
  self.notifier_version = args[:notifier_version]
  self.notifier_url     = args[:notifier_url]

  self.ignore              = args[:ignore]              || []
  self.ignore_by_filters   = args[:ignore_by_filters]   || []
  self.backtrace_filters   = args[:backtrace_filters]   || []
  self.params_filters      = args[:params_filters]      || []
  self.parameters          = args[:parameters] ||
                               action_dispatch_params ||
                               rack_env(:params) ||
                               {}
  self.component           = args[:component] || args[:controller] || parameters['controller']
  self.action              = args[:action] || parameters['action']

  self.environment_name = args[:environment_name]
  self.cgi_data         = args[:cgi_data] || args[:rack_env]
  self.backtrace        = Backtrace.parse(exception_attribute(:backtrace, caller), :filters => self.backtrace_filters)
  self.error_class      = exception_attribute(:error_class) {|exception| exception.class.name }
  self.error_message    = exception_attribute(:error_message, 'Notification') do |exception|
    "#{exception.class.name}: #{args[:error_message] || exception.message}"
  end

  self.hostname        = local_hostname
  self.user = args[:user]

  also_use_rack_params_filters
  find_session_data
  clean_params
  clean_rack_request_data
end

Public Instance Methods

[](method) click to toggle source

Allows properties to be accessed using a hash-like syntax

@example

notice[:error_message]

@param [String] method The given key for an attribute @return The attribute value, or self if given :request

# File lib/airbrake/notice.rb, line 221
def [](method)
  case method
  when :request
    self
  else
    send(method)
  end
end
ignore?() click to toggle source

Determines if this notice should be ignored

# File lib/airbrake/notice.rb, line 210
def ignore?
  ignored_class_names.include?(error_class) ||
    ignore_by_filters.any? {|filter| filter.call(self) }
end
to_xml() click to toggle source

Converts the given notice to XML

# File lib/airbrake/notice.rb, line 144
def to_xml
  builder = Builder::XmlMarkup.new
  builder.instruct!
  xml = builder.notice(:version => Airbrake::API_VERSION) do |notice|
    notice.tag!("api-key", api_key)
    notice.notifier do |notifier|
      notifier.name(notifier_name)
      notifier.version(notifier_version)
      notifier.url(notifier_url)
    end
    notice.error do |error|
      error.tag!('class', error_class)
      error.message(error_message)
      error.backtrace do |backtrace|
        self.backtrace.lines.each do |line|
          backtrace.line(:number => line.number,
                         :file   => line.file,
                         :method => line.method)
        end
      end
    end
    if url ||
        controller ||
        action ||
        !parameters.blank? ||
        !cgi_data.blank? ||
        !session_data.blank?
      notice.request do |request|
        request.url(url)
        request.component(controller)
        request.action(action)
        unless parameters.nil? || parameters.empty?
          request.params do |params|
            xml_vars_for(params, parameters)
          end
        end
        unless session_data.nil? || session_data.empty?
          request.session do |session|
            xml_vars_for(session, session_data)
          end
        end
        unless cgi_data.nil? || cgi_data.empty?
          request.tag!("cgi-data") do |cgi_datum|
            xml_vars_for(cgi_datum, cgi_data)
          end
        end
      end
    end
    notice.tag!("server-environment") do |env|
      env.tag!("project-root", project_root)
      env.tag!("environment-name", environment_name)
      env.tag!("hostname", hostname)
    end
    unless user.blank?
      notice.tag!("current-user") do |u|
        u.tag!("id",user[:id])
        u.tag!("name",user[:name])
        u.tag!("email",user[:email])
        u.tag!("username",user[:username])
      end
    end
  end
  xml.to_s
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.