Skip to content

Commit

Permalink
fix(dbm-services): 修正查询模拟执行任务返回的状态码 #8660
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq authored and iSecloud committed Dec 17, 2024
1 parent 9e165b4 commit 639e93b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions dbm-services/common/go-pubpkg/errno/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ package errno
var (
// OK TODO
OK = Errno{Code: 0, Message: "", CNMessage: ""}
// SimulationTaskFailed 语义检查失败
SimulationTaskFailed = Errno{Code: 1, Message: "simulation failed", CNMessage: "模拟执行失败"}

// InternalServerError TODO
InternalServerError = Errno{Code: 10001, Message: "Internal server error", CNMessage: "服务器内部错误。"}
Expand Down
5 changes: 3 additions & 2 deletions dbm-services/mysql/db-simulation/handler/dbsimulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/gin-gonic/gin"

"dbm-services/common/go-pubpkg/cmutil"
"dbm-services/common/go-pubpkg/errno"
"dbm-services/common/go-pubpkg/logger"
"dbm-services/mysql/db-simulation/app/service"
"dbm-services/mysql/db-simulation/model"
Expand Down Expand Up @@ -121,7 +122,7 @@ func (s *SimulationHandler) QueryTask(c *gin.Context) {
switch task.Status {
case model.TaskFailed:
allSuccessful = false
s.SendResponse(c, fmt.Errorf("%s", task.SysErrMsg), map[string]interface{}{
s.SendResponse(c, errno.SimulationTaskFailed.Add(task.SysErrMsg), map[string]interface{}{
"simulation_version": task.MySQLVersion,
"stdout": task.Stdout,
"stderr": task.Stderr,
Expand All @@ -131,7 +132,7 @@ func (s *SimulationHandler) QueryTask(c *gin.Context) {
allSuccessful = true
default:
allSuccessful = false
s.SendResponse(c, fmt.Errorf("unknown transition state"), map[string]interface{}{
s.SendResponse(c, errno.SimulationTaskFailed.Add("unknown transition state"), map[string]interface{}{
"stdout": task.Stdout,
"stderr": task.Stderr,
"errmsg": fmt.Sprintf("the program has been run with abnormal status:%s", task.Status)})
Expand Down

0 comments on commit 639e93b

Please sign in to comment.