【增加错误提示】

This commit is contained in:
weizhihong 2023-09-26 10:25:24 +08:00
parent f323aa9465
commit 239fa341bf
1 changed files with 5 additions and 1 deletions

View File

@ -43,7 +43,11 @@ func InitServer() *gin.Engine {
engine.Use(ginzap.CustomRecoveryWithZap(zap.L(), true, func(c *gin.Context, e interface{}) {
switch e := e.(type) {
case error:
c.JSON(http.StatusInternalServerError, e)
c.JSON(http.StatusInternalServerError, &dto.ErrorDto{
Code: dto.LogicError,
Tip: dto.ErrorTipMap[dto.LogicError],
Message: e.Error(),
})
case dto.ErrorDto:
e.Tip = dto.ErrorTipMap[e.Code]
c.JSON(http.StatusInternalServerError, e)