Module: ScoutApmMcp::McpErrorIdPatch

Defined in:
lib/scout_apm_mcp/mcp_error_id_patch.rb

Class Method Summary collapse

Class Method Details

.apply!(target) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/scout_apm_mcp/mcp_error_id_patch.rb', line 7

def self.apply!(target)
  return unless target.private_method_defined?(:send_error) || target.method_defined?(:send_error)

  target.class_eval do
    alias_method :original_send_error, :send_error

    define_method(:send_error) do |code, message, id = nil|
      id = "error_#{SecureRandom.hex(8)}" if id.nil?
      original_send_error(code, message, id)
    end
  end
end