Class: LogBrew::Rails::ErrorReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/logbrew/rails_integration.rb

Overview

Rails.error subscriber for handled reports. Unhandled errors stay owned by the request middleware so one exception cannot create two issues.

Constant Summary collapse

CONTEXT_KEYS =
%w[controller action].freeze

Instance Method Summary collapse

Constructor Details

#initialize(runtime) ⇒ ErrorReporter

Returns a new instance of ErrorReporter.



938
939
940
941
942
943
# File 'lib/logbrew/rails_integration.rb', line 938

def initialize(runtime)
  @runtime = runtime
  @mutex = Mutex.new
  @subscriber_client = nil
  @subscriber = nil
end

Instance Method Details

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



945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/logbrew/rails_integration.rb', line 945

def report(error, handled: true, severity: :error, context: nil, source: nil, **options)
  return nil unless handled

  active_client = @runtime.client
  return nil if active_client.nil?

  subscriber_for(active_client).report(
    error,
    handled: true,
    severity: severity,
    context: safe_context(context),
    source: bounded_source(source),
    **options
  )
rescue StandardError => capture_error
  @runtime.report_error("handled_error_capture", capture_error)
  nil
end