Skip to content

Commit

Permalink
udate err check
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMaster482 committed Dec 13, 2023
1 parent 2848efa commit d41e28d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
5 changes: 2 additions & 3 deletions internal/microservices/auth/delivery/http/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package http

import (
"encoding/json"
"errors"
"net/http"
"time"

Expand Down Expand Up @@ -80,8 +79,8 @@ func (h *Handler) SignUp(w http.ResponseWriter, r *http.Request) {
Password: signUpUser.PlaintPassword,
})
if err != nil {
errUserAlreadyExists := status.Error(codes.AlreadyExists, "Alredy exist") //*models.UserAlreadyExistsError
if errors.As(err, &errUserAlreadyExists) {
// errUserAlreadyExists := status.Error(codes.AlreadyExists, "Alredy exist") //*models.UserAlreadyExistsError
if status.Code(err) == codes.AlreadyExists {
response.ErrorResponse(w, http.StatusConflict, err, "User already exists", h.log)
return
}
Expand Down
19 changes: 9 additions & 10 deletions internal/microservices/category/repository/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"errors"
"fmt"

"github.com/jackc/pgx/v4"

"github.com/go-park-mail-ru/2023_2_Hamster/cmd/api/init/db/postgresql"
"github.com/go-park-mail-ru/2023_2_Hamster/internal/common/logger"
"github.com/go-park-mail-ru/2023_2_Hamster/internal/models"
Expand Down Expand Up @@ -37,7 +35,7 @@ const (
WHERE user_id = $1 AND id = $2
);`

transactionAssociationDelete = "DELETE FROM TransactionCategory WHERE category_id = $1;"
// transactionAssociationDelete = "DELETE FROM TransactionCategory WHERE category_id = $1;"
)

type Repository struct {
Expand Down Expand Up @@ -209,10 +207,11 @@ func (r *Repository) CheckExist(ctx context.Context, userId uuid.UUID, tagId uui
return true, nil
}

func (r *Repository) deleteTransactionAssociations(ctx context.Context, tx pgx.Tx, tagID uuid.UUID) error {
_, err := tx.Exec(ctx, transactionAssociationDelete, tagID)
if err != nil {
return fmt.Errorf("[repo] failed to delete existing transaction associations: %w", err)
}
return nil
}
//
// func (r *Repository) deleteTransactionAssociations(ctx context.Context, tx pgx.Tx, tagID uuid.UUID) error {
// _, err := tx.Exec(ctx, transactionAssociationDelete, tagID)
// if err != nil {
// return fmt.Errorf("[repo] failed to delete existing transaction associations: %w", err)
// }
// return nil
// }

0 comments on commit d41e28d

Please sign in to comment.