【增加错误提示】
This commit is contained in:
parent
f323aa9465
commit
239fa341bf
6
init.go
6
init.go
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue