Skip to content
Snippets Groups Projects
Commit 63f8e3f5 authored by Rémi PAILHAREY's avatar Rémi PAILHAREY :fork_knife_plate:
Browse files

Merge branch 'deleting-non-existing-consent-returns-404' into 'dev'

fix: deleting non existing consent returns 404

See merge request !101
parents 97464b1b b41a6851
No related branches found
No related tags found
2 merge requests!102Release to master,!101fix: deleting non existing consent returns 404
Pipeline #99381 passed
......@@ -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
}
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment