Skip to content

Commit 2aecb55

Browse files
committed
[users] improve errors handling
1 parent 054c976 commit 2aecb55

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

internal/sms-gateway/users/module.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ func Module() fx.Option {
1010
return fx.Module(
1111
"users",
1212
logger.WithNamedLogger("users"),
13+
fx.Provide(newRepository, fx.Private),
1314
)
1415
}
1516

internal/sms-gateway/users/repository.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,11 @@ func (r *repository) Insert(user *User) error {
4141
}
4242

4343
func (r *repository) UpdatePassword(ID string, passwordHash string) error {
44-
return r.db.Model((*User)(nil)).Where("id = ?", ID).Update("password_hash", passwordHash).Error
44+
if err := r.db.Model((*User)(nil)).
45+
Where("id = ?", ID).
46+
Update("password_hash", passwordHash).Error; err != nil {
47+
return fmt.Errorf("can't update password: %w", err)
48+
}
49+
50+
return nil
4551
}

0 commit comments

Comments
 (0)