From 106c612e635816954bc6d5c217d2aee5d43f559b Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Fri, 6 Jun 2025 16:31:31 -0300 Subject: [PATCH] feat(user,service): return error on incorect construct parameter --- service/user.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/service/user.go b/service/user.go index 45f21a9..3b485c9 100644 --- a/service/user.go +++ b/service/user.go @@ -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) {