diff --git a/internal/models/grdfConsent.go b/internal/models/grdfConsent.go index 0ab5fc1191a8be3a5ec3ae9589b6c1f11668233a..da7b0b67e6e01cb0f255b6a9eac1960941f18c25 100644 --- a/internal/models/grdfConsent.go +++ b/internal/models/grdfConsent.go @@ -130,7 +130,11 @@ func (dh *DataHandler) DeleteGrdfConsentById(w http.ResponseWriter, r *http.Requ var consent = GrdfConsent{} err = dh.sqlClient.First(&consent, "id = ?", id).Error if err != nil { - http.Error(w, "couldn't find consent", http.StatusInternalServerError) + if errors.Is(err, gorm.ErrRecordNotFound) { + http.Error(w, "consent not found", http.StatusNotFound) + return + } + http.Error(w, "error while finding consent", http.StatusInternalServerError) log.Println(err.Error()) return } diff --git a/internal/models/sgeConsent.go b/internal/models/sgeConsent.go index b3278c57b02e233fca156a821f906997e6a73491..c2366660dd19794c8478d5b4e5648b3f4892bb14 100644 --- a/internal/models/sgeConsent.go +++ b/internal/models/sgeConsent.go @@ -217,7 +217,11 @@ func (dh *DataHandler) DeleteSgeConsentById(w http.ResponseWriter, r *http.Reque var consent = SgeConsent{} err = dh.sqlClient.First(&consent, "id = ?", id).Error if err != nil { - http.Error(w, "couldn't find consent", http.StatusInternalServerError) + if errors.Is(err, gorm.ErrRecordNotFound) { + http.Error(w, "consent not found", http.StatusNotFound) + return + } + http.Error(w, "error while finding consent", http.StatusInternalServerError) log.Println(err.Error()) return }