fix: update to check for ErrDuplicatedKey and return a more specific but generic error if so
This commit is contained in:
parent
6ff84bbc1a
commit
d946e969bc
|
@ -100,6 +100,9 @@ func (s *AccountServiceDefault) CreateAccount(email string, password string, ver
|
|||
|
||||
result := s.db.Create(&user)
|
||||
if result.Error != nil {
|
||||
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
|
||||
return nil, NewAccountError(ErrKeyEmailAlreadyExists, nil)
|
||||
}
|
||||
return nil, NewAccountError(ErrKeyAccountCreationFailed, result.Error)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue