Skip to content

Commit 16a1445

Browse files
committed
add NewGitHubRawAPIErrorResponse back
1 parent 0a6760d commit 16a1445

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/errors/error.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ func NewGitHubGraphQLErrorResponse(ctx context.Context, message string, err erro
163163
return utils.NewToolResultErrorFromErr(message, err)
164164
}
165165

166+
// NewGitHubRawAPIErrorResponse returns an mcp.NewToolResultError and retains the error in the context for access via middleware
167+
func NewGitHubRawAPIErrorResponse(ctx context.Context, message string, resp *http.Response, err error) *mcp.CallToolResult {
168+
rawErr := newGitHubRawAPIError(message, resp, err)
169+
if ctx != nil {
170+
_, _ = addRawAPIErrorToContext(ctx, rawErr) // Explicitly ignore error for graceful handling
171+
}
172+
return utils.NewToolResultErrorFromErr(message, err)
173+
}
174+
166175
// NewGitHubAPIStatusErrorResponse handles cases where the API call succeeds (err == nil)
167176
// but returns an unexpected HTTP status code. It creates a synthetic error from the
168177
// status code and response body, then records it in context for observability tracking.

0 commit comments

Comments
 (0)