mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-21 15:11:08 +08:00
Go: Fix error code (#16807)
### Summary As title. --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -188,7 +188,7 @@ func (h *SystemHandler) SetLogLevel(c *gin.Context) {
|
||||
func (h *SystemHandler) ListVariables(c *gin.Context) {
|
||||
variables, err := h.systemService.ListAllVariables()
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, 500, err.Error())
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -206,22 +206,22 @@ type SetVariableHTTPRequest struct {
|
||||
func (h *SystemHandler) SetVariable(c *gin.Context) {
|
||||
var req SetVariableHTTPRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
common.ErrorWithCode(c, 400, "Var name is required")
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Var name is required")
|
||||
return
|
||||
}
|
||||
|
||||
if req.VarName == "" {
|
||||
common.ErrorWithCode(c, 400, "Var name is required")
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Var name is required")
|
||||
return
|
||||
}
|
||||
|
||||
if req.VarValue == "" {
|
||||
common.ErrorWithCode(c, 400, "Var value is required")
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Var value is required")
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.systemService.SetVariable(req.VarName, req.VarValue); err != nil {
|
||||
common.ErrorWithCode(c, 500, err.Error())
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -233,17 +233,17 @@ func (h *SystemHandler) ShowVariable(c *gin.Context) {
|
||||
|
||||
varName, err := common.DecodeFromBase64(encodedVarName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, 400, err.Error())
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if varName == "" {
|
||||
common.ErrorWithCode(c, 400, "Var name is required")
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, "Var name is required")
|
||||
return
|
||||
}
|
||||
|
||||
variable, err := h.systemService.ShowVariable(varName)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, 500, err.Error())
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ func (h *SystemHandler) ShowVariable(c *gin.Context) {
|
||||
func (h *SystemHandler) ListEnvironments(c *gin.Context) {
|
||||
environments, err := h.systemService.ListEnvironments()
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, 500, err.Error())
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user