sumbissions: return correct http error code
This commit is contained in:
parent
b5bb79c6ef
commit
185a1d147f
@ -2,8 +2,10 @@ package service_internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
"errors"
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
|
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,6 +17,9 @@ type Service struct {
|
|||||||
// yay duplicate code
|
// yay duplicate code
|
||||||
func (svc *Service) NewError(ctx context.Context, err error) *internal.ErrorStatusCode {
|
func (svc *Service) NewError(ctx context.Context, err error) *internal.ErrorStatusCode {
|
||||||
status := 500
|
status := 500
|
||||||
|
if errors.Is(err, datastore.ErrNotExist) {
|
||||||
|
status = 404
|
||||||
|
}
|
||||||
return &internal.ErrorStatusCode{
|
return &internal.ErrorStatusCode{
|
||||||
StatusCode: status,
|
StatusCode: status,
|
||||||
Response: internal.Error{
|
Response: internal.Error{
|
||||||
|
Loading…
Reference in New Issue
Block a user