Skip to content

Commit

Permalink
Update user.go
Browse files Browse the repository at this point in the history
fix:  GetUserByID 
when user not exits, resp is nil then it will nill address error
  • Loading branch information
huhaiqwer authored Jun 19, 2024
1 parent 6734fd4 commit f9a8454
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apiv2/pkg/clients/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ func (c *RESTClient) GetUserByID(ctx context.Context, id int64) (*model.UserResp
params.WithTimeout(c.Options.Timeout)

resp, err := c.V2Client.User.GetUser(params, c.AuthInfo)


if err != nil {
return nil, handleSwaggerUserErrors(err)
}

if resp.Payload == nil {
return nil, &clienterrors.ErrUserNotFound{}
}
Expand All @@ -120,9 +124,6 @@ func (c *RESTClient) GetUserByID(ctx context.Context, id int64) (*model.UserResp
return nil, &clienterrors.ErrUserInvalidID{}
}

if err != nil {
return nil, handleSwaggerUserErrors(err)
}

return resp.Payload, nil
}
Expand Down

0 comments on commit f9a8454

Please sign in to comment.