🎨 updated error handling logic

This commit is contained in:
landaiqing
2024-11-18 01:12:50 +08:00
parent 78a162a19a
commit 35d2da35b2
48 changed files with 395 additions and 170 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/common/utils"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/client"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
@@ -18,7 +19,11 @@ func GenerateClientIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp, err := l.GenerateClientId(clientIP)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(r.Context(), w, http.StatusInternalServerError, resp)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}