From 185a1d147fa7fdefe9daa6c4839bccbe2747b9d3 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 17 Dec 2024 19:12:13 -0800 Subject: [PATCH] sumbissions: return correct http error code --- pkg/service_internal/service_internal.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/service_internal/service_internal.go b/pkg/service_internal/service_internal.go index 9513793..7826495 100644 --- a/pkg/service_internal/service_internal.go +++ b/pkg/service_internal/service_internal.go @@ -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{