Exception: SmilyCli::McpError

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

Overview

Raised when an MCP interaction fails: a JSON-RPC error envelope, a tool that returns isError: true, a missing session, or a transport failure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code: nil) ⇒ McpError

Returns a new instance of McpError.

Parameters:

  • message (String)
  • code (Integer, nil) (defaults to: nil)


36
37
38
39
# File 'lib/smily_cli/errors.rb', line 36

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

Instance Attribute Details

#codeInteger? (readonly)

Returns JSON-RPC error code, when present.

Returns:

  • (Integer, nil)

    JSON-RPC error code, when present



32
33
34
# File 'lib/smily_cli/errors.rb', line 32

def code
  @code
end

Instance Method Details

#exit_statusObject



41
42
43
44
# File 'lib/smily_cli/errors.rb', line 41

def exit_status
  # -32000 "Unauthorized", -32001 "Session not found" map to auth failures.
  [-32_000, -32_001].include?(code) ? 3 : 1
end