Exception: McpToolkit::Protocol::Error
- Inherits:
-
StandardError
- Object
- StandardError
- McpToolkit::Protocol::Error
- Defined in:
- lib/mcp_toolkit/protocol.rb
Overview
Base protocol error. code/data land verbatim in the JSON-RPC error
object via #to_h; the dispatcher turns a raised Error into a top-level
JSON-RPC error response (the envelope a client sees for a bad tool arg or an
unknown method).
Direct Known Subclasses
InternalError, InvalidParams, InvalidRequest, MethodNotFound, ParseError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(message, code:, data: nil) ⇒ Error
constructor
A new instance of Error.
- #to_h ⇒ Object
Constructor Details
#initialize(message, code:, data: nil) ⇒ Error
Returns a new instance of Error.
46 47 48 49 50 |
# File 'lib/mcp_toolkit/protocol.rb', line 46 def initialize(, code:, data: nil) super() @code = code @data = data end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
44 45 46 |
# File 'lib/mcp_toolkit/protocol.rb', line 44 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
44 45 46 |
# File 'lib/mcp_toolkit/protocol.rb', line 44 def data @data end |
Instance Method Details
#to_h ⇒ Object
52 53 54 55 56 |
# File 'lib/mcp_toolkit/protocol.rb', line 52 def to_h error = { code:, message: } error[:data] = data if data error end |