Class: Hutch::ErrorHandlers::Airbrake

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

Instance Method Summary collapse

Methods included from Logging

#logger, logger, logger=, setup_logger

Instance Method Details

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



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/hutch/error_handlers/airbrake.rb', line 9

def handle(properties, payload, consumer, ex)
  message_id = properties.message_id
  prefix = "message(#{message_id || '-'}):"
  logger.error "#{prefix} Logging event to Airbrake"
  logger.error "#{prefix} #{ex.class} - #{ex.message}"

  if ::Airbrake.respond_to?(:notify_or_ignore)
    ::Airbrake.notify_or_ignore(ex, {
      error_class: ex.class.name,
      error_message: "#{ ex.class.name }: #{ ex.message }",
      backtrace: ex.backtrace,
      parameters: {
        payload: payload,
        consumer: consumer,
      },
      cgi_data: ENV.to_hash,
    })
  else
    ::Airbrake.notify(ex, {
      payload: payload,
      consumer: consumer,
      cgi_data: ENV.to_hash,
    })
  end
end

#handle_setup_exception(ex) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hutch/error_handlers/airbrake.rb', line 35

def handle_setup_exception(ex)
  logger.error "Logging setup exception to Airbrake"
  logger.error "#{ex.class} - #{ex.message}"

  if ::Airbrake.respond_to?(:notify_or_ignore)
    ::Airbrake.notify_or_ignore(ex, {
      error_class: ex.class.name,
      error_message: "#{ ex.class.name }: #{ ex.message }",
      backtrace: ex.backtrace,
      cgi_data: ENV.to_hash,
    })
  else
    ::Airbrake.notify(ex, {
      cgi_data: ENV.to_hash,
    })
  end
end