Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'web/controller/util.go')
-rw-r--r--web/controller/util.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/web/controller/util.go b/web/controller/util.go
index b11203bd..3d266f29 100644
--- a/web/controller/util.go
+++ b/web/controller/util.go
@@ -50,8 +50,17 @@ func jsonMsgObj(c *gin.Context, msg string, obj any, err error) {
}
} else {
m.Success = false
- m.Msg = msg + " (" + err.Error() + ")"
- logger.Warning(msg+" "+I18nWeb(c, "fail")+": ", err)
+ errStr := err.Error()
+ if errStr != "" {
+ m.Msg = msg + " (" + errStr + ")"
+ logger.Warning(msg+" "+I18nWeb(c, "fail")+": ", err)
+ } else if msg != "" {
+ m.Msg = msg
+ logger.Warning(msg + " " + I18nWeb(c, "fail"))
+ } else {
+ m.Msg = I18nWeb(c, "somethingWentWrong")
+ logger.Warning(I18nWeb(c, "somethingWentWrong") + " " + I18nWeb(c, "fail"))
+ }
}
c.JSON(http.StatusOK, m)
}