feat(user,service): return error on incorect construct parameter

This commit is contained in:
Guz
2025-06-06 16:31:31 -03:00
parent 06807b0623
commit 106c612e63

View File

@@ -17,10 +17,12 @@ type UserService struct {
repo *repository.UserRepository
}
func NewUserService(repo *repository.UserRepository, assert tinyssert.Assertions) *UserService {
assert.NotNil(repo)
func NewUserService(repo *repository.UserRepository, assert tinyssert.Assertions) (*UserService, error) {
if err := assert.NotNil(repo); err != nil {
return nil, err
}
return &UserService{repo: repo, assert: assert}
return &UserService{repo: repo, assert: assert}, nil
}
func (s *UserService) Register(username, password string) (model.User, error) {