Skip to content

Commit

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

import "errors"

type Error struct {
CustomError error
}

var (
ErrUserAlreadyExists = Error{CustomError: errors.New("user already exists")}
ErrUserAlreadyExists = errors.New("user 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.CustomError) {
if errors.Is(err, models.ErrUserAlreadyExists) {
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.CustomError
return models.ErrUserAlreadyExists
}
}
return err
Expand Down

0 comments on commit 832a1f6

Please sign in to comment.