Class: Airbrake::Filters::ExceptionAttributesFilter Private

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/airbrake-ruby/filters/exception_attributes_filter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

ExceptionAttributesFilter attempts to call ‘#to_airbrake` on the stashed exception and attaches returned data to the notice object.

Since:

  • v2.10.0

Instance Method Summary collapse

Methods included from Loggable

#logger

Constructor Details

#initializeExceptionAttributesFilter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ExceptionAttributesFilter.

Since:

  • v2.10.0



11
12
13
# File 'lib/airbrake-ruby/filters/exception_attributes_filter.rb', line 11

def initialize
  @weight = 118
end

Instance Method Details

#call(notice) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

This is a mandatory method required by any filter integrated with FilterChain.

Parameters:

  • notice (Notice)

    the notice to be filtered

See Also:

Since:

  • v2.10.0



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/airbrake-ruby/filters/exception_attributes_filter.rb', line 16

def call(notice) # rubocop:disable Metrics/AbcSize
  exception = notice.stash[:exception]
  return unless exception.respond_to?(:to_airbrake)

  attributes = nil
  begin
    attributes = exception.to_airbrake
  rescue StandardError => ex
    logger.error(
      "#{LOG_LABEL} #{exception.class}#to_airbrake failed. #{ex.class}: #{ex}",
    )
  end

  unless attributes.is_a?(Hash)
    logger.error(
      "#{LOG_LABEL} #{self.class}: wanted Hash, got #{attributes.class}",
    )
    return
  end

  attributes.each do |key, attrs|
    if notice[key]
      notice[key].merge!(attrs)
    else
      notice[key] = attrs
    end
  end
end