From b09f20c838b83524e9fa57032d3466fa7db92a85 Mon Sep 17 00:00:00 2001 From: "kim (grufwub)" Date: Fri, 27 Aug 2021 09:07:34 +0100 Subject: [PATCH] fix basicDB.Put() to properly process error Signed-off-by: kim (grufwub) --- internal/db/bundb/basic.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/internal/db/bundb/basic.go b/internal/db/bundb/basic.go index acf706b65..3c2dfb4eb 100644 --- a/internal/db/bundb/basic.go +++ b/internal/db/bundb/basic.go @@ -21,7 +21,6 @@ package bundb import ( "context" "errors" - "strings" "github.com/sirupsen/logrus" "github.com/superseriousbusiness/gotosocial/internal/config" @@ -37,10 +36,7 @@ type basicDB struct { func (b *basicDB) Put(ctx context.Context, i interface{}) db.Error { _, err := b.conn.NewInsert().Model(i).Exec(ctx) - if err != nil && strings.Contains(err.Error(), "duplicate key value violates unique constraint") { - return db.ErrAlreadyExists - } - return err + return b.conn.ProcessError(err) } func (b *basicDB) GetByID(ctx context.Context, id string, i interface{}) db.Error {