MCPcopy Create free account
hub / github.com/github/gh-aw / mcpErrorData

Function mcpErrorData

pkg/cli/mcp_error.go:17–28  ·  view source on GitHub ↗

mcpErrorData marshals data to JSON for use in jsonrpc.Error.Data field. Returns nil if marshaling fails to avoid errors in error handling.

(v any)

Source from the content-addressed store, hash-verified

15// mcpErrorData marshals data to JSON for use in jsonrpc.Error.Data field.
16// Returns nil if marshaling fails to avoid errors in error handling.
17func mcpErrorData(v any) json.RawMessage {
18 if v == nil {
19 return nil
20 }
21 data, err := json.Marshal(v)
22 if err != nil {
23 // Log the error but return nil to avoid breaking error handling
24 mcpLog.Printf("Failed to marshal error data: %v", err)
25 return nil
26 }
27 return data
28}

Callers 5

TestMcpErrorData_NilFunction · 0.85
TestMcpErrorData_StringFunction · 0.85
TestMcpErrorData_MapFunction · 0.85
newMCPErrorFunction · 0.85

Calls 1

PrintfMethod · 0.45

Tested by 4

TestMcpErrorData_NilFunction · 0.68
TestMcpErrorData_StringFunction · 0.68
TestMcpErrorData_MapFunction · 0.68