diff --git a/pkg/datastore/datastore.go b/pkg/datastore/datastore.go index 69a848e..52a1ee5 100644 --- a/pkg/datastore/datastore.go +++ b/pkg/datastore/datastore.go @@ -8,6 +8,7 @@ import ( var ( ErrNotExist = errors.New("resource does not exist") + ErroNoRowsAffected = errors.New("query did not affect any rows") ) type Datastore interface { diff --git a/pkg/datastore/gormstore/submissions.go b/pkg/datastore/gormstore/submissions.go index 4a32751..43893bb 100644 --- a/pkg/datastore/gormstore/submissions.go +++ b/pkg/datastore/gormstore/submissions.go @@ -10,10 +10,6 @@ import ( "gorm.io/gorm/clause" ) -var ( - ErrorStatus = errors.New("Status is not in allowed statuses") -) - type Submissions struct { db *gorm.DB } @@ -85,7 +81,7 @@ func (env *Submissions) IfStatusThenUpdateAndGet(ctx context.Context, id int64, } if result.RowsAffected == 0 { - return submission, ErrorStatus + return submission, datastore.ErroNoRowsAffected } return submission, nil diff --git a/pkg/service/submissions.go b/pkg/service/submissions.go index d6585f6..39ca1c1 100644 --- a/pkg/service/submissions.go +++ b/pkg/service/submissions.go @@ -3,17 +3,12 @@ package service import ( "context" "encoding/json" - "errors" "git.itzana.me/strafesnet/maps-service/pkg/api" "git.itzana.me/strafesnet/maps-service/pkg/datastore" "git.itzana.me/strafesnet/maps-service/pkg/model" ) -var ( - // ErrInvalidSourceStatus current submission status cannot change to destination status - ErrInvalidSourceStatus = errors.New("Invalid source status") -) // POST /submissions func (svc *Service) CreateSubmission(ctx context.Context, request *api.SubmissionCreate) (*api.ID, error) {