fix: 在 PullCodeHandler 和 BuildBotHandler 中添加错误日志记录,提升错误处理的可追溯性

This commit is contained in:
lixiangwuxian 2025-05-05 02:26:56 +08:00
parent d0d3898694
commit 5b7a5a5aca
2 changed files with 10 additions and 0 deletions

View File

@ -181,6 +181,7 @@ func PullCodeHandler(c *gin.Context) {
err := util.GitPull()
log.Println("拉取代码...")
if err != nil {
log.Println(err)
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
@ -197,6 +198,7 @@ func BuildBotHandler(c *gin.Context) {
err := buildBot()
log.Println("构建程序...")
if err != nil {
log.Println(err)
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}

View File

@ -58,5 +58,13 @@ func GitPull() error {
return errors.New(string(forceResetOutput) + err.Error())
}
// 拉取最新代码
pullCmd := exec.Command("git", "pull")
pullCmd.Dir = workDir
pullOutput, err := pullCmd.CombinedOutput()
if err != nil {
return errors.New(string(pullOutput) + err.Error())
}
return nil
}