From e94f7ad3806f9caf09c382642aff35df3df76f3c Mon Sep 17 00:00:00 2001 From: Ulrich Eckhardt Date: Tue, 9 Jan 2024 15:06:45 +0100 Subject: [PATCH] rest-api/main.go properly signal duplicate external UUIDs --- rest-api/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest-api/main.go b/rest-api/main.go index daa6aa8..2ff0f24 100644 --- a/rest-api/main.go +++ b/rest-api/main.go @@ -70,7 +70,10 @@ func Serve(ctx context.Context, store events.EventStore) error { envelope, err := store.Insert(c.Request().Context(), external_uuid, request.asEvent(), 0) if err != nil { c.Logger().Error(err) - return c.String(http.StatusBadRequest, "bad request") + if err == events.DuplicateEventUUID { + return c.String(http.StatusConflict, "duplicate event") + } + return c.String(http.StatusInternalServerError, "failed to insert new event") } response := newResponseDTO(envelope)