Class: RubyLLM::MCP::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/mcp/error.rb

Instance Method Summary collapse

Constructor Details

#initialize(error_data) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
# File 'lib/ruby_llm/mcp/error.rb', line 6

def initialize(error_data)
  @code = error_data["code"]
  @message = error_data["message"]
  @data = error_data["data"]
end

Instance Method Details

#to_sObject



29
30
31
# File 'lib/ruby_llm/mcp/error.rb', line 29

def to_s
  "Error: code: #{@code} (#{type}), message: #{@message}, data: #{@data}"
end

#typeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby_llm/mcp/error.rb', line 12

def type
  case @code
  when -32_700
    :parse_error
  when -32_600
    :invalid_request
  when -32_601
    :method_not_found
  when -32_602
    :invalid_params
  when -32_603
    :internal_error
  else
    :custom_error
  end
end