Class: Tpt::Rails::Internal::ErrorReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/tpt/rails/internal/error_reporter.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(bugsnag_api_key: nil, rollbar_access_token: nil, rollbar_enabled: false) ⇒ ErrorReporter

Returns a new instance of ErrorReporter.



2
3
4
5
6
7
8
9
# File 'lib/tpt/rails/internal/error_reporter.rb', line 2

def initialize(bugsnag_api_key: nil, rollbar_access_token: nil, rollbar_enabled: false)
  @bugsnag_api_key = bugsnag_api_key
  @rollbar_access_token = rollbar_access_token
  @rollbar_enabled = rollbar_enabled

  configure_bugsnag if bugsnag?
  configure_rollbar if rollbar?
end

Instance Method Details

#report(error) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tpt/rails/internal/error_reporter.rb', line 11

def report(error)
  if bugsnag?
    Bugsnag.notify(error)
  end

  if rollbar?
    Rollbar.error(error)
  end

  Tpt::Rails.statsd.increment(
    'error',
    tags: [
      "error_class:#{error.class.name.underscore}",
      'type:reported',
    ],
  )

  ::Rails.logger.info("Error: class=#{error.class} message=#{error.message.inspect}")

  if !bugsnag? && !rollbar?
    ::Rails.logger.info('Warning: No error reporter configured for Tpt::Rails. Please add one.')
    ::Rails.logger.info(error.backtrace)
  end
end