🎨 updated error handling logic
This commit is contained in:
@@ -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/internal/logic/sms"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/types"
|
||||
@@ -23,7 +24,11 @@ func SendSmsByAliyunHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
resp, err := l.SendSmsByAliyun(&req)
|
||||
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)
|
||||
}
|
||||
|
@@ -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/internal/logic/sms"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/types"
|
||||
@@ -23,7 +24,11 @@ func SendSmsBySmsbaoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
resp, err := l.SendSmsBySmsbao(&req)
|
||||
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)
|
||||
}
|
||||
|
@@ -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/internal/logic/sms"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/types"
|
||||
@@ -23,7 +24,11 @@ func SendSmsByTestHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
resp, err := l.SendSmsByTest(&req)
|
||||
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user