Skip to content

Commit f9a8454

Browse files
authored
Update user.go
fix: GetUserByID when user not exits, resp is nil then it will nill address error
1 parent 6734fd4 commit f9a8454

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

apiv2/pkg/clients/user/user.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ func (c *RESTClient) GetUserByID(ctx context.Context, id int64) (*model.UserResp
111111
params.WithTimeout(c.Options.Timeout)
112112

113113
resp, err := c.V2Client.User.GetUser(params, c.AuthInfo)
114-
114+
115+
if err != nil {
116+
return nil, handleSwaggerUserErrors(err)
117+
}
118+
115119
if resp.Payload == nil {
116120
return nil, &clienterrors.ErrUserNotFound{}
117121
}
@@ -120,9 +124,6 @@ func (c *RESTClient) GetUserByID(ctx context.Context, id int64) (*model.UserResp
120124
return nil, &clienterrors.ErrUserInvalidID{}
121125
}
122126

123-
if err != nil {
124-
return nil, handleSwaggerUserErrors(err)
125-
}
126127

127128
return resp.Payload, nil
128129
}

0 commit comments

Comments
 (0)