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

Function checkAPIResponse

backend/api/mcp/tool_change.go:561–573  ·  view source on GitHub ↗

checkAPIResponse checks an API response for permission or general errors. Returns nil if the response is OK, or a structured error otherwise.

(resp *apiResponse, operation, permission string)

Source from the content-addressed store, hash-verified

559// checkAPIResponse checks an API response for permission or general errors.
560// Returns nil if the response is OK, or a structured error otherwise.
561func checkAPIResponse(resp *apiResponse, operation, permission string) error {
562 if resp.Status == http.StatusForbidden || resp.Status == http.StatusUnauthorized {
563 return &toolError{
564 Code: "PERMISSION_DENIED",
565 Message: fmt.Sprintf("you don't have permission to %s", operation),
566 Suggestion: fmt.Sprintf("ask your workspace admin to grant you the %s permission", permission),
567 }
568 }
569 if resp.Status >= 400 {
570 return errors.Errorf("%s failed: HTTP %d: %s", operation, resp.Status, parseError(resp.Body))
571 }
572 return nil
573}
574
575// formatChangeError formats a changeError into an MCP error result.
576func formatChangeError(err *changeError) *mcp.CallToolResult {

Callers 2

createIssueMethod · 0.85
callAPIMethod · 0.85

Calls 2

parseErrorFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected