Exception: LLM::MCP::Error

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

Instance Attribute Summary collapse

Attributes inherited from Error

#response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Error

#message

Constructor Details

#initialize(message, code = nil, data = nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • message (String)

    The error message

  • code (Integer) (defaults to: nil)

    The error code

  • data (Object) (defaults to: nil)

    Additional error data provided by the MCP process



23
24
25
26
27
# File 'lib/llm/mcp/error.rb', line 23

def initialize(message, code = nil, data = nil)
  super(message)
  @code = code
  @data = data
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/llm/mcp/error.rb', line 5

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/llm/mcp/error.rb', line 5

def data
  @data
end

Class Method Details

.from(response:) ⇒ LLM::MCP::Error

Parameters:

  • response (Hash)

    The full response from the MCP process, including the error object

Returns:



11
12
13
14
# File 'lib/llm/mcp/error.rb', line 11

def self.from(response:)
  error = response.fetch("error")
  new(*error.values_at("message", "code", "data"))
end