@@ -340,7 +340,7 @@ func GetIssue(ctx context.Context, client *github.Client, cache *lockdown.RepoAc
340340 if err != nil {
341341 return nil , fmt .Errorf ("failed to read response body: %w" , err )
342342 }
343- return utils . NewToolResultError ( fmt . Sprintf ( "failed to get issue: %s " , string ( body )) ), nil
343+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to get issue" , resp , body ), nil
344344 }
345345
346346 if flags .LockdownMode {
@@ -396,7 +396,7 @@ func GetIssueComments(ctx context.Context, client *github.Client, cache *lockdow
396396 if err != nil {
397397 return nil , fmt .Errorf ("failed to read response body: %w" , err )
398398 }
399- return utils . NewToolResultError ( fmt . Sprintf ( "failed to get issue comments: %s " , string ( body )) ), nil
399+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to get issue comments" , resp , body ), nil
400400 }
401401 if flags .LockdownMode {
402402 if cache == nil {
@@ -455,7 +455,7 @@ func GetSubIssues(ctx context.Context, client *github.Client, cache *lockdown.Re
455455 if err != nil {
456456 return nil , fmt .Errorf ("failed to read response body: %w" , err )
457457 }
458- return utils . NewToolResultError ( fmt . Sprintf ( "failed to list sub-issues: %s " , string ( body )) ), nil
458+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to list sub-issues" , resp , body ), nil
459459 }
460460
461461 if featureFlags .LockdownMode {
@@ -588,7 +588,7 @@ func ListIssueTypes(t translations.TranslationHelperFunc) inventory.ServerTool {
588588 if err != nil {
589589 return utils .NewToolResultErrorFromErr ("failed to read response body" , err ), nil , nil
590590 }
591- return utils . NewToolResultError ( fmt . Sprintf ( "failed to list issue types: %s " , string ( body )) ), nil , nil
591+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to list issue types" , resp , body ), nil , nil
592592 }
593593
594594 r , err := json .Marshal (issueTypes )
@@ -673,7 +673,7 @@ func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool
673673 if err != nil {
674674 return utils .NewToolResultErrorFromErr ("failed to read response body" , err ), nil , nil
675675 }
676- return utils . NewToolResultError ( fmt . Sprintf ( "failed to create comment: %s " , string ( body )) ), nil , nil
676+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to create comment" , resp , body ), nil , nil
677677 }
678678
679679 r , err := json .Marshal (createdComment )
@@ -823,7 +823,7 @@ func AddSubIssue(ctx context.Context, client *github.Client, owner string, repo
823823 if err != nil {
824824 return nil , fmt .Errorf ("failed to read response body: %w" , err )
825825 }
826- return utils . NewToolResultError ( fmt . Sprintf ( "failed to add sub-issue: %s " , string ( body )) ), nil
826+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to add sub-issue" , resp , body ), nil
827827 }
828828
829829 r , err := json .Marshal (subIssue )
@@ -855,7 +855,7 @@ func RemoveSubIssue(ctx context.Context, client *github.Client, owner string, re
855855 if err != nil {
856856 return nil , fmt .Errorf ("failed to read response body: %w" , err )
857857 }
858- return utils . NewToolResultError ( fmt . Sprintf ( "failed to remove sub-issue: %s " , string ( body )) ), nil
858+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to remove sub-issue" , resp , body ), nil
859859 }
860860
861861 r , err := json .Marshal (subIssue )
@@ -904,7 +904,7 @@ func ReprioritizeSubIssue(ctx context.Context, client *github.Client, owner stri
904904 if err != nil {
905905 return nil , fmt .Errorf ("failed to read response body: %w" , err )
906906 }
907- return utils . NewToolResultError ( fmt . Sprintf ( "failed to reprioritize sub-issue: %s " , string ( body )) ), nil
907+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to reprioritize sub-issue" , resp , body ), nil
908908 }
909909
910910 r , err := json .Marshal (subIssue )
@@ -1195,7 +1195,7 @@ func CreateIssue(ctx context.Context, client *github.Client, owner string, repo
11951195 if err != nil {
11961196 return utils .NewToolResultErrorFromErr ("failed to read response body" , err ), nil
11971197 }
1198- return utils . NewToolResultError ( fmt . Sprintf ( "failed to create issue: %s " , string ( body )) ), nil
1198+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to create issue" , resp , body ), nil
11991199 }
12001200
12011201 // Return minimal response with just essential information
@@ -1256,7 +1256,7 @@ func UpdateIssue(ctx context.Context, client *github.Client, gqlClient *githubv4
12561256 if err != nil {
12571257 return nil , fmt .Errorf ("failed to read response body: %w" , err )
12581258 }
1259- return utils . NewToolResultError ( fmt . Sprintf ( "failed to update issue: %s " , string ( body )) ), nil
1259+ return ghErrors . NewGitHubAPIStatusErrorResponse ( ctx , "failed to update issue" , resp , body ), nil
12601260 }
12611261
12621262 // Use GraphQL API for state updates
0 commit comments