Skip to content

Commit

Permalink
propagate other errors in GetUserByEmail
Browse files Browse the repository at this point in the history
  • Loading branch information
micolous committed Oct 8, 2024
1 parent a5465e5 commit ee7f917
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hscontrol/db/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@ func (hsdb *HSDatabase) GetUserByEmail(email string) (*types.User, error) {

func GetUserByEmail(tx *gorm.DB, email string) (*types.User, error) {
user := types.User{}
if result := tx.First(&user, "email = ?", email); errors.Is(
result.Error,
gorm.ErrRecordNotFound,
) {
result := tx.First(&user, "email = ?", email)

if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return nil, ErrUserNotFound
}
if result.Error != nil {
return nil, result.Error
}

return &user, nil
}
Expand Down

0 comments on commit ee7f917

Please sign in to comment.