Class: SolidErrors::Frontend::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_errors/frontend/reporter.rb

Overview

Hands a browser error to Rails' error reporter.

SolidErrors::Subscriber is a plain ErrorSubscriber, so this is the way in: going to SolidErrors::Error directly would bypass its sanitizer, fingerprint dedup and occurrence creation. It also means solid_errors need not be loaded at all — in an environment with no subscriber the report simply goes nowhere, which is why the gem works in development and test.

Instance Method Summary collapse

Constructor Details

#initialize(report, context: {}, source_mapper: SourceMapper.new) ⇒ Reporter

Returns a new instance of Reporter.



12
13
14
15
16
# File 'lib/solid_errors/frontend/reporter.rb', line 12

def initialize(report, context: {}, source_mapper: SourceMapper.new)
  @report = report
  @context = context
  @source_mapper = source_mapper
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/solid_errors/frontend/reporter.rb', line 18

def call
  error = build_error
  log(error) if SolidErrors::Frontend.log_reports?

  Rails.error.report(
    error,
    handled: @report.handled?,
    severity: @report.severity,
    source: @report.source,
    context: context
  )
end