change error message to make more sense
This commit is contained in:
parent
119bb79a88
commit
2a04efb10b
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
ErrNotExist = errors.New("resource does not exist")
|
ErrNotExist = errors.New("resource does not exist")
|
||||||
|
ErroNoRowsAffected = errors.New("query did not affect any rows")
|
||||||
)
|
)
|
||||||
|
|
||||||
type Datastore interface {
|
type Datastore interface {
|
||||||
|
@ -10,10 +10,6 @@ import (
|
|||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
ErrorStatus = errors.New("Status is not in allowed statuses")
|
|
||||||
)
|
|
||||||
|
|
||||||
type Submissions struct {
|
type Submissions struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
}
|
}
|
||||||
@ -85,7 +81,7 @@ func (env *Submissions) IfStatusThenUpdateAndGet(ctx context.Context, id int64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if result.RowsAffected == 0 {
|
if result.RowsAffected == 0 {
|
||||||
return submission, ErrorStatus
|
return submission, datastore.ErroNoRowsAffected
|
||||||
}
|
}
|
||||||
|
|
||||||
return submission, nil
|
return submission, nil
|
||||||
|
@ -3,17 +3,12 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
"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
|
// POST /submissions
|
||||||
func (svc *Service) CreateSubmission(ctx context.Context, request *api.SubmissionCreate) (*api.ID, error) {
|
func (svc *Service) CreateSubmission(ctx context.Context, request *api.SubmissionCreate) (*api.ID, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user