Module: Hitch::MCP::Internal::LocalDiagnosis

Defined in:
app/models/hitch/mcp/internal/local_diagnosis.rb

Overview

A client must learn nothing from a host failure; the developer who wrote it must learn everything. Those are two audiences and only the first is a threat, so in development and test the real exception goes to the local log. Callers' wire responses are unchanged, and production stays silent.

Class Method Summary collapse

Class Method Details

.report(subject, error = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/hitch/mcp/internal/local_diagnosis.rb', line 14

def report(subject, error = nil)
  return unless Rails.env.local?

  lines = [ "[hitch] #{subject}" ]
  if error
    lines << "  #{error.class}: #{error.message}"
    lines.concat(Array(error.backtrace).first(5).map { |line| "    #{line}" })
  end
  Rails.logger&.error(lines.join("\n"))
  nil
# Diagnosing a failure must not become one.
rescue StandardError, SystemStackError
  nil
end