Exception: VectorMCP::ProtocolError

Inherits:
Error
  • Object
show all
Defined in:
lib/vector_mcp/errors.rb

Overview

Base class for all JSON-RPC 2.0 errors that the VectorMCP library can emit. It mirrors the structure defined by the JSON-RPC spec and adds a flexible details field that implementers may use to attach structured, implementation-specific metadata to an error payload.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code: -32_600,, details: nil, request_id: nil) ⇒ ProtocolError

Initializes a new ProtocolError.

Parameters:

  • message (String)

    The error message.

  • code (Integer) (defaults to: -32_600,)

    The JSON-RPC error code.

  • details (Hash, nil) (defaults to: nil)

    Additional details for the error (optional).

  • request_id (String, Integer, nil) (defaults to: nil)

    The ID of the originating request.



30
31
32
33
34
35
36
37
38
# File 'lib/vector_mcp/errors.rb', line 30

def initialize(message, code: -32_600, details: nil, request_id: nil)
  logger = VectorMCP.logger_for("errors")
  logger.debug("Initializing ProtocolError with code: #{code}")
  @code = code
  @message = message
  @details = details # NOTE: `data` in JSON-RPC is often used for this purpose.
  @request_id = request_id
  super(message)
end

Instance Attribute Details

#codeInteger (readonly)

Returns The JSON-RPC error code.

Returns:

  • (Integer)

    The JSON-RPC error code.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vector_mcp/errors.rb', line 20

class ProtocolError < Error
  attr_accessor :request_id
  attr_reader :code, :message, :details

  # Initializes a new ProtocolError.
  #
  # @param message [String] The error message.
  # @param code [Integer] The JSON-RPC error code.
  # @param details [Hash, nil] Additional details for the error (optional).
  # @param request_id [String, Integer, nil] The ID of the originating request.
  def initialize(message, code: -32_600, details: nil, request_id: nil)
    logger = VectorMCP.logger_for("errors")
    logger.debug("Initializing ProtocolError with code: #{code}")
    @code = code
    @message = message
    @details = details # NOTE: `data` in JSON-RPC is often used for this purpose.
    @request_id = request_id
    super(message)
  end
end

#detailsHash? (readonly)

Returns Additional implementation-specific details for the error (optional).

Returns:

  • (Hash, nil)

    Additional implementation-specific details for the error (optional).



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vector_mcp/errors.rb', line 20

class ProtocolError < Error
  attr_accessor :request_id
  attr_reader :code, :message, :details

  # Initializes a new ProtocolError.
  #
  # @param message [String] The error message.
  # @param code [Integer] The JSON-RPC error code.
  # @param details [Hash, nil] Additional details for the error (optional).
  # @param request_id [String, Integer, nil] The ID of the originating request.
  def initialize(message, code: -32_600, details: nil, request_id: nil)
    logger = VectorMCP.logger_for("errors")
    logger.debug("Initializing ProtocolError with code: #{code}")
    @code = code
    @message = message
    @details = details # NOTE: `data` in JSON-RPC is often used for this purpose.
    @request_id = request_id
    super(message)
  end
end

#messageString (readonly)

Returns A short description of the error.

Returns:

  • (String)

    A short description of the error.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vector_mcp/errors.rb', line 20

class ProtocolError < Error
  attr_accessor :request_id
  attr_reader :code, :message, :details

  # Initializes a new ProtocolError.
  #
  # @param message [String] The error message.
  # @param code [Integer] The JSON-RPC error code.
  # @param details [Hash, nil] Additional details for the error (optional).
  # @param request_id [String, Integer, nil] The ID of the originating request.
  def initialize(message, code: -32_600, details: nil, request_id: nil)
    logger = VectorMCP.logger_for("errors")
    logger.debug("Initializing ProtocolError with code: #{code}")
    @code = code
    @message = message
    @details = details # NOTE: `data` in JSON-RPC is often used for this purpose.
    @request_id = request_id
    super(message)
  end
end

#request_idString, ...

Returns The ID of the request that caused this error, if applicable.

Returns:

  • (String, Integer, nil)

    The ID of the request that caused this error, if applicable.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vector_mcp/errors.rb', line 20

class ProtocolError < Error
  attr_accessor :request_id
  attr_reader :code, :message, :details

  # Initializes a new ProtocolError.
  #
  # @param message [String] The error message.
  # @param code [Integer] The JSON-RPC error code.
  # @param details [Hash, nil] Additional details for the error (optional).
  # @param request_id [String, Integer, nil] The ID of the originating request.
  def initialize(message, code: -32_600, details: nil, request_id: nil)
    logger = VectorMCP.logger_for("errors")
    logger.debug("Initializing ProtocolError with code: #{code}")
    @code = code
    @message = message
    @details = details # NOTE: `data` in JSON-RPC is often used for this purpose.
    @request_id = request_id
    super(message)
  end
end