From 639e93b1384366413d969d57788d263927272ec6 Mon Sep 17 00:00:00 2001 From: yuanruji Date: Tue, 17 Dec 2024 15:28:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(dbm-services):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A8=A1=E6=8B=9F=E6=89=A7=E8=A1=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E8=BF=94=E5=9B=9E=E7=9A=84=E7=8A=B6=E6=80=81=E7=A0=81?= =?UTF-8?q?=20#8660?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-services/common/go-pubpkg/errno/code.go | 2 ++ dbm-services/mysql/db-simulation/handler/dbsimulation.go | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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)})