Class: Hutch::ErrorHandlers::Honeybadger

Inherits:
Base
  • Object
show all
Defined in:
lib/hutch/error_handlers/honeybadger.rb

Overview

Error handler for the Honeybadger.io service

Instance Method Summary collapse

Methods included from Logging

#logger, logger, logger=, setup_logger

Instance Method Details

#handle(properties, payload, consumer, ex) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hutch/error_handlers/honeybadger.rb', line 10

def handle(properties, payload, consumer, ex)
  message_id = properties.message_id
  prefix = "message(#{message_id || '-'}):"
  logger.error "#{prefix} Logging event to Honeybadger"
  logger.error "#{prefix} #{ex.class} - #{ex.message}"
  notify_honeybadger(error_class: ex.class.name,
                     error_message: "#{ex.class.name}: #{ex.message}",
                     backtrace: ex.backtrace,
                     context: { message_id: message_id,
                                consumer: consumer },
                     parameters: { payload: payload })
end

#handle_setup_exception(ex) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/hutch/error_handlers/honeybadger.rb', line 23

def handle_setup_exception(ex)
  logger.error "Logging setup exception to Honeybadger"
  logger.error "#{ex.class} - #{ex.message}"
  notify_honeybadger(error_class: ex.class.name,
                     error_message: "#{ex.class.name}: #{ex.message}",
                     backtrace: ex.backtrace)
end

#notify_honeybadger(message) ⇒ Object

Wrap API to support 3.0.0+



34
35
36
37
38
39
40
# File 'lib/hutch/error_handlers/honeybadger.rb', line 34

def notify_honeybadger(message)
  if ::Honeybadger.respond_to?(:notify_or_ignore)
    ::Honeybadger.notify_or_ignore(message)
  else
    ::Honeybadger.notify(message)
  end
end