sumbissions: return correct http error code

This commit is contained in:
Quaternions 2024-12-17 19:12:13 -08:00
parent b5bb79c6ef
commit 185a1d147f

View File

@ -2,8 +2,10 @@ package service_internal
import (
"context"
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
"errors"
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
"github.com/nats-io/nats.go"
)
@ -15,6 +17,9 @@ type Service struct {
// yay duplicate code
func (svc *Service) NewError(ctx context.Context, err error) *internal.ErrorStatusCode {
status := 500
if errors.Is(err, datastore.ErrNotExist) {
status = 404
}
return &internal.ErrorStatusCode{
StatusCode: status,
Response: internal.Error{