Class: Hitch::MCP::Internal::SanitizedReport

Inherits:
Object
  • Object
show all
Defined in:
app/models/hitch/mcp/internal/sanitized_report.rb

Overview

Reports a synthetic failure with caller-fixed context through the host error reporter. The original exception never crosses this boundary, and every reporting failure is swallowed.

Class Method Summary collapse

Class Method Details

.emit(source:, context:, message:) ⇒ Object



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

def emit(source:, context:, message:)
  return unless Rails.respond_to?(:error)

  failure = ReportedFailure.new(message)
  failure.set_backtrace(caller(1, 8))
  failure.freeze
  Rails.error.report(
    failure,
    handled: true,
    severity: :error,
    context: context,
    source: source
  )
  nil
rescue StandardError, SystemStackError
  nil
end