Include error info in some functions (#27)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/27
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: yp05327 <576951401@qq.com>
Co-committed-by: yp05327 <576951401@qq.com>
This commit is contained in:
yp05327
2025-04-11 06:06:16 +00:00
committed by hiifong
parent f656c92cda
commit fac6e1d8d1
2 changed files with 3 additions and 3 deletions

View File

@@ -145,7 +145,7 @@ func CreateIssueFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR
Body: body, Body: body,
}) })
if err != nil { if err != nil {
return to.ErrorResult(fmt.Errorf("create %v/%v/issue err", owner, repo)) return to.ErrorResult(fmt.Errorf("create %v/%v/issue err: %v", owner, repo, err))
} }
return to.TextResult(issue) return to.TextResult(issue)
@@ -174,7 +174,7 @@ func CreateIssueCommentFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.Ca
} }
issueComment, _, err := gitea.Client().CreateIssueComment(owner, repo, int64(index), opt) issueComment, _, err := gitea.Client().CreateIssueComment(owner, repo, int64(index), opt)
if err != nil { if err != nil {
return to.ErrorResult(fmt.Errorf("create %v/%v/issue/%v/comment err", owner, repo, int64(index))) return to.ErrorResult(fmt.Errorf("create %v/%v/issue/%v/comment err: %v", owner, repo, int64(index), err))
} }
return to.TextResult(issueComment) return to.TextResult(issueComment)

View File

@@ -148,7 +148,7 @@ func ForkRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResu
} }
_, _, err := gitea.Client().CreateFork(user, repo, opt) _, _, err := gitea.Client().CreateFork(user, repo, opt)
if err != nil { if err != nil {
return to.ErrorResult(fmt.Errorf("fork repository error %v", err)) return to.ErrorResult(fmt.Errorf("fork repository error: %v", err))
} }
return to.TextResult("Fork success") return to.TextResult("Fork success")
} }