From 36a51f83abec2a71e979def52f143fc65ab1c00c Mon Sep 17 00:00:00 2001 From: Mihaela Balutoiu Date: Mon, 17 Oct 2022 17:46:56 +0300 Subject: [PATCH] Fixed error wrap The error is not wrapped correctly, because instead of using `q.Error`, it uses `err`, which is defined elsewhere. Also, the `UpdateRepository` and `CreateRepositoryPool` functions will never fail on update/create repo, because it returns a nil error, instead of wrap error. Signed-off-by: Mihaela Balutoiu --- database/sql/repositories.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/sql/repositories.go b/database/sql/repositories.go index c97daf43..f1d61426 100644 --- a/database/sql/repositories.go +++ b/database/sql/repositories.go @@ -125,7 +125,7 @@ func (s *sqlDatabase) UpdateRepository(ctx context.Context, repoID string, param q := s.conn.Save(&repo) if q.Error != nil { - return params.Repository{}, errors.Wrap(err, "saving repo") + return params.Repository{}, errors.Wrap(q.Error, "saving repo") } newParams := s.sqlToCommonRepository(repo) @@ -196,7 +196,7 @@ func (s *sqlDatabase) CreateRepositoryPool(ctx context.Context, repoId string, p q := s.conn.Create(&newPool) if q.Error != nil { - return params.Pool{}, errors.Wrap(err, "adding pool") + return params.Pool{}, errors.Wrap(q.Error, "adding pool") } for _, tt := range tags {