module ActiveSupport::Testing::ErrorReporterAssertions::ErrorCollector

def record

def record
  subscribe
  recorders = ActiveSupport::IsolatedExecutionState[:active_support_error_reporter_assertions] ||= []
  reports = []
  recorders << reports
  begin
    yield
    reports
  ensure
    recorders.delete_if { |r| reports.equal?(r) }
  end
end

def report(error, **kwargs)

def report(error, **kwargs)
  report = Report.new(error: error, **kwargs)
  ActiveSupport::IsolatedExecutionState[:active_support_error_reporter_assertions]&.each do |reports|
    reports << report
  end
  true
end

def subscribe

def subscribe
  return if @subscribed
  @mutex.synchronize do
    return if @subscribed
    if ActiveSupport.error_reporter
      ActiveSupport.error_reporter.subscribe(self)
      @subscribed = true
    else
      raise Minitest::Assertion, "No error reporter is configured"
    end
  end
end