MCPcopy Create free account
hub / github.com/bytebase/bytebase / parseError

Function parseError

backend/api/mcp/tool_http.go:69–81  ·  view source on GitHub ↗

parseError extracts the error message from an API error response body.

(body json.RawMessage)

Source from the content-addressed store, hash-verified

67
68// parseError extracts the error message from an API error response body.
69func parseError(body json.RawMessage) string {
70 var errMap map[string]any
71 if json.Unmarshal(body, &errMap) != nil {
72 return ""
73 }
74 if msg, ok := errMap["message"].(string); ok {
75 return msg
76 }
77 if code, ok := errMap["code"].(string); ok {
78 return code
79 }
80 return ""
81}
82
83// toolError is a structured error returned by MCP tools.
84type toolError struct {

Callers 6

executeQueryMethod · 0.85
checkAPIResponseFunction · 0.85
listDatabasesMethod · 0.85
translateMetadataErrorFunction · 0.85
handleCallAPIMethod · 0.85

Calls 1

UnmarshalMethod · 0.80

Tested by 1