Skip to content

Commit 1dfee9a

Browse files
authored
添加user中err处理
1 parent 7f60305 commit 1dfee9a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

service/user/user.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ func register(c *gin.Context) {
5252
Email: obj.Email,
5353
PhoneNumber: obj.PhoneNumber,
5454
})
55+
if err != nil {
56+
c.JSON(http.StatusOK, gin.H{
57+
"result": gin.H{
58+
"code": errorcode.ServerInternalNetworkError,
59+
"msg": err.Error(),
60+
},
61+
})
62+
return
63+
}
5564
if ret.Result.Code != errorcode.Success {
5665
c.JSON(http.StatusOK, gin.H{
5766
"result": gin.H{
@@ -96,6 +105,15 @@ func login(c *gin.Context) {
96105
Username: obj.Username,
97106
Password: obj.Password,
98107
})
108+
if err != nil {
109+
c.JSON(http.StatusOK, gin.H{
110+
"result": gin.H{
111+
"code": errorcode.ServerInternalNetworkError,
112+
"msg": err.Error(),
113+
},
114+
})
115+
return
116+
}
99117
if ret.Result.Code != errorcode.Success {
100118
c.JSON(http.StatusOK, gin.H{
101119
"result": gin.H{

0 commit comments

Comments
 (0)