Class: Honeybadger::Config::Callbacks

Inherits:
Object
  • Object
show all
Defined in:
lib/honeybadger/config/callbacks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCallbacks

Returns a new instance of Callbacks.



6
7
8
9
10
# File 'lib/honeybadger/config/callbacks.rb', line 6

def initialize
  @backtrace_filter = nil
  @exception_filter = nil
  @exception_fingerprint = nil
end

Instance Attribute Details

#backtrace_filter(&block) ⇒ Object (readonly)

Public: Takes a block and adds it to the list of backtrace filters. When the filters run, the block will be handed each line of the backtrace and can modify it as necessary.

&block - The new backtrace filter.

Examples:

config.backtrace_filter do |line|
  line.gsub(/^#{Rails.root}/, "[Rails.root]")
end

Yields a line in the backtrace.



25
26
27
# File 'lib/honeybadger/config/callbacks.rb', line 25

def backtrace_filter
  @backtrace_filter
end

#exception_filter(&block) ⇒ Object (readonly)

Public: Takes a block and adds it to the list of ignore filters. When the filters run, the block will be handed the exception.

&block - The new ignore filter

If the block returns true the exception will be ignored, otherwise it
will be processed by honeybadger.

Examples:

config.exception_filter do |exception|
  if exception.class < MyError
    nil
  else
    exception
  end
end

Yields the the exception data given to Honeybadger.notify



48
49
50
# File 'lib/honeybadger/config/callbacks.rb', line 48

def exception_filter
  @exception_filter
end

#exception_fingerprintObject (readonly)

Public: Generate custom fingerprint (optional)

block - An optional block returning object responding to #to_s

Examples

config.exception_fingerprint do |notice|
  [notice[:error_class], notice[:component], notice[:backtrace].to_s].join(':')
end

Returns configured fingerprint generator (should respond to #call(notice))



64
65
66
# File 'lib/honeybadger/config/callbacks.rb', line 64

def exception_fingerprint
  @exception_fingerprint
end