MCPcopy
hub / github.com/github/github-mcp-server / NewGitHubAPIStatusErrorResponse

Function NewGitHubAPIStatusErrorResponse

pkg/errors/error.go:217–220  ·  view source on GitHub ↗

NewGitHubAPIStatusErrorResponse handles cases where the API call succeeds (err == nil) but returns an unexpected HTTP status code. It creates a synthetic error from the status code and response body, then records it in context for observability tracking.

(ctx context.Context, message string, resp *github.Response, body []byte)

Source from the content-addressed store, hash-verified

215// but returns an unexpected HTTP status code. It creates a synthetic error from the
216// status code and response body, then records it in context for observability tracking.
217func NewGitHubAPIStatusErrorResponse(ctx context.Context, message string, resp *github.Response, body []byte) *mcp.CallToolResult {
218 err := fmt.Errorf("unexpected status %d: %s", resp.StatusCode, string(body))
219 return NewGitHubAPIErrorResponse(ctx, message, resp, err)
220}

Callers 1

TestGitHubErrorContextFunction · 0.85

Calls 1

Tested by 1

TestGitHubErrorContextFunction · 0.68