diff --git a/dbm-services/common/go-pubpkg/errno/code.go b/dbm-services/common/go-pubpkg/errno/code.go index 95b7407e4d..a9f7ea44b4 100644 --- a/dbm-services/common/go-pubpkg/errno/code.go +++ b/dbm-services/common/go-pubpkg/errno/code.go @@ -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: "服务器内部错误。"} diff --git a/dbm-services/mysql/db-simulation/handler/dbsimulation.go b/dbm-services/mysql/db-simulation/handler/dbsimulation.go index e2bdf50777..141a0caf2a 100644 --- a/dbm-services/mysql/db-simulation/handler/dbsimulation.go +++ b/dbm-services/mysql/db-simulation/handler/dbsimulation.go @@ -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" @@ -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, @@ -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)})