Module: Roqua::Support::Errors

Defined in:
lib/roqua/support/errors.rb

Class Method Summary collapse

Class Method Details

.add_parameters(params) ⇒ Object

adds instance variable roqua_extra_parameters to current exception.



15
16
17
18
19
20
# File 'lib/roqua/support/errors.rb', line 15

def self.add_parameters(params)
  return unless params.is_a?(Hash) && $!
  $!.instance_eval do
    (@roqua_extra_parameters ||= {}).merge! params
  end
end

.appsignal_namespace_for_category(category) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/roqua/support/errors.rb', line 32

def self.appsignal_namespace_for_category(category)
  case category
  when :background then Appsignal::Transaction::BACKGROUND_JOB
  when :web then        Appsignal::Transaction::HTTP_REQUEST
  when :hl7 then        'hl7'
  else                  Appsignal::Transaction::BLANK
  end
end

.extra_parametersObject

global extra parameters to be added to all reports.



5
6
7
# File 'lib/roqua/support/errors.rb', line 5

def self.extra_parameters
  @extra_parameters || {}
end

.extra_parameters=(hash) ⇒ Object



9
10
11
12
# File 'lib/roqua/support/errors.rb', line 9

def self.extra_parameters=(hash)
  fail 'not a hash' unless hash.is_a? Hash
  @extra_parameters = hash
end

.report(exception, context = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/roqua/support/errors.rb', line 22

def self.report(exception, context = {})
  return if const_defined?(:Rails) && Rails.env.test?

  namespace, parameters, _controller, skip_backtrace = merge_parameters(exception, context)
  notification_urls = [notify_appsignal(exception, parameters, namespace)]

  # Notify Roqua logging
  log_exception(exception, parameters, notification_urls.compact, skip_backtrace)
end