Skip to content

Commit

Permalink
rest-api/main.go properly signal duplicate external UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
UlrichEckhardt committed Jan 9, 2024
1 parent f387509 commit e94f7ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rest-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e94f7ad

Please sign in to comment.