From 9cd3b389b22545dc35520fb9c1217cc558abec42 Mon Sep 17 00:00:00 2001 From: Alexis Poyen <apoyen@mail.apoyen.fr> Date: Thu, 30 Apr 2020 16:41:23 +0200 Subject: [PATCH] Fix: send correct error number --- internal/models/bankers.go | 4 ++-- internal/models/clients.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/models/bankers.go b/internal/models/bankers.go index f038367..7be006c 100644 --- a/internal/models/bankers.go +++ b/internal/models/bankers.go @@ -119,12 +119,12 @@ func (d *DataHandler) postBankerAdmin(w http.ResponseWriter, r *http.Request, id // check userID is not already present in DB var client UserClient if err := d.db.Where(reqUserID, o.UserID).First(&client).Error; err == nil { - http.Error(w, "UserID is already bind to a Client", http.StatusNotFound) + http.Error(w, "UserID is already bind to a Client", http.StatusInternalServerError) return } var banker UserBanker if err := d.db.Where(reqUserID, o.UserID).First(&banker).Error; err == nil { - http.Error(w, "UserID is already bind to a Banker", http.StatusNotFound) + http.Error(w, "UserID is already bind to a Banker", http.StatusInternalServerError) return } d.db.Create(&o) diff --git a/internal/models/clients.go b/internal/models/clients.go index 55871c6..f8ebc1a 100644 --- a/internal/models/clients.go +++ b/internal/models/clients.go @@ -139,12 +139,12 @@ func (d *DataHandler) postClientAdmin(w http.ResponseWriter, r *http.Request, id // check userID is not already present in DB var client UserClient if err := d.db.Where(reqUserID, o.UserID).First(&client).Error; err == nil { - http.Error(w, "UserID is already bind to a Client", http.StatusNotFound) + http.Error(w, "UserID is already bind to a Client", http.StatusInternalServerError) return } var banker UserBanker if err := d.db.Where(reqUserID, o.UserID).First(&banker).Error; err == nil { - http.Error(w, "UserID is already bind to a Banker", http.StatusNotFound) + http.Error(w, "UserID is already bind to a Banker", http.StatusInternalServerError) return } d.db.Create(&o) -- GitLab