Class: SolidEvents::Subscribers::ErrorSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_events/subscribers/error_subscriber.rb

Instance Method Summary collapse

Instance Method Details

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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/solid_events/subscribers/error_subscriber.rb', line 8

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

  trace = SolidEvents::Tracer.current_trace || SolidEvents::Tracer.consume_bound_trace_for_exception(error)
  return unless trace

  fingerprint = error_fingerprint(error, severity: severity, source: source)
  persist_fingerprint(trace, fingerprint)
  solid_error = find_solid_error_by_fingerprint(fingerprint)
  solid_error ||= find_solid_error_by_exception(error, trace: trace)

  return unless solid_error

  trace.error_links.find_or_create_by!(solid_error_id: solid_error.id)
rescue StandardError
  nil
end