Skip to content

Commit

Permalink
errors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
timurIsaevIY committed Oct 23, 2024
1 parent 832a1f6 commit dbff1c6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/models/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package models
import "errors"

var (
ErrUserAlreadyExists = errors.New("user already exists")
ErrAlreadyExists = errors.New("already exists")
)
2 changes: 1 addition & 1 deletion internal/pkg/auth/delivery/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (h *Handler) SignUp(w http.ResponseWriter, r *http.Request) {

err := h.usecase.SignUp(context.Background(), user)
if err != nil {
if errors.Is(err, models.ErrUserAlreadyExists) {
if errors.Is(err, models.ErrAlreadyExists) {
response := httpresponse.ErrorResponse{
Message: "user already exists",
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/auth/repo/auth_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (r *RepositoryImpl) CreateUser(ctx context.Context, user models.User) error
if err != nil {
var pqErr *pq.Error
if errors.As(err, &pqErr) && pqErr.Code == "23505" {
return models.ErrUserAlreadyExists
return models.ErrAlreadyExists
}
}
return err
Expand Down

0 comments on commit dbff1c6

Please sign in to comment.