Class: Raises::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/raises/subscriber.rb

Instance Method Summary collapse

Instance Method Details

#report(error, handled:, severity:, context:, source: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/raises/subscriber.rb', line 9

def report(error, handled:, severity:, context:, source: nil)
  return unless report?

  notice = {
    env: env_name,
    revision: revision,
    handled: handled,
    error: {
      class: error.class.name,
      message: error.message.to_s,
      backtrace: Array(error.backtrace)
    },
    context: json_safe(context_without_request(context).merge(severity: severity.to_s, source: source)),
    request: request_from(context)
  }

  post(notice)
rescue StandardError => e
  warn("raises subscriber failed: #{e.class}: #{e.message}")
end