Skip to content

Commit b6ca0cf

Browse files
fix: Replace direct error equality judgment with errors.Is to prevent panic (#1198)
Co-authored-by: ruibo.qin <qinphantom@gmail.com>
1 parent 7c020ad commit b6ca0cf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

user/handler/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ func (h *UserHandler) Update(ctx *gin.Context) {
157157
err = h.c.UpdateByUUID(ctx.Request.Context(), req)
158158
if err != nil {
159159
slog.ErrorContext(ctx.Request.Context(), "Failed to update user by uuid", slog.Any("error", err), slog.String("uuid", *req.UUID), slog.String("current_user", currentUser), slog.Any("req", *req))
160-
if err == errorx.ErrForbidden {
160+
if errors.Is(err, errorx.ErrForbidden) {
161161
httpbase.ForbiddenError(ctx, err)
162162
return
163163
}
164-
if err == errorx.ErrUserNotFound {
164+
if errors.Is(err, errorx.ErrUserNotFound) {
165165
httpbase.NotFoundError(ctx, err)
166166
return
167167
}

0 commit comments

Comments
 (0)