Exception: McpOnRuby::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/mcp_on_ruby/errors.rb

Overview

Base error class for MCP-related errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Error.



8
9
10
11
12
# File 'lib/mcp_on_ruby/errors.rb', line 8

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.



6
7
8
# File 'lib/mcp_on_ruby/errors.rb', line 6

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/mcp_on_ruby/errors.rb', line 6

def data
  @data
end

Instance Method Details

#to_json_rpcObject

Convert error to JSON-RPC error format



15
16
17
18
19
20
21
# File 'lib/mcp_on_ruby/errors.rb', line 15

def to_json_rpc
  {
    code: @code || default_error_code,
    message: message,
    data: @data
  }.compact
end