style(backend): lowercase error messages across handlers
Normalize error message casing to lowercase for consistency across auth, bookings, services, customer relationship, and profile handlers. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/mail"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -136,9 +135,8 @@ func RegisterHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate email format
|
// Validate email format
|
||||||
_, err := mail.ParseAddress(req.Email)
|
if err := validators.ValidateEmail(req.Email); err != nil {
|
||||||
if err != nil {
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
http.Error(w, "invalid email format", http.StatusBadRequest)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -687,7 +687,7 @@ func GetAllAdminBookingsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
func GetAllBookingsByUserHandler(w http.ResponseWriter, r *http.Request) {
|
func GetAllBookingsByUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userID := chi.URLParam(r, "user_id")
|
userID := chi.URLParam(r, "user_id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ func ServicesHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
func ServicesEligibleForUserHandler(w http.ResponseWriter, r *http.Request) {
|
func ServicesEligibleForUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userID := chi.URLParam(r, "user_id")
|
userID := chi.URLParam(r, "user_id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,7 +406,7 @@ func ServicesEligibleForUserHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
var dob time.Time
|
var dob time.Time
|
||||||
err := db.DB.QueryRow(r.Context(), `SELECT date_of_birth FROM users WHERE id = $1`, userID).Scan(&dob)
|
err := db.DB.QueryRow(r.Context(), `SELECT date_of_birth FROM users WHERE id = $1`, userID).Scan(&dob)
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ type TopService struct {
|
|||||||
func GetCustomerRelationshipHandler(w http.ResponseWriter, r *http.Request) {
|
func GetCustomerRelationshipHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userID := chi.URLParam(r, "id")
|
userID := chi.URLParam(r, "id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ func GetCustomerRelationshipHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !exists {
|
if !exists {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ func UpdateProfileHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
func GetAdminUserHandler(w http.ResponseWriter, r *http.Request) {
|
func GetAdminUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userID := chi.URLParam(r, "id")
|
userID := chi.URLParam(r, "id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +330,7 @@ func GetAdminUserHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("Failed to fetch user %s: %v", userID, err)
|
log.Printf("Failed to fetch user %s: %v", userID, err)
|
||||||
@@ -610,7 +610,7 @@ type ServiceForPatchTest struct {
|
|||||||
func GetEligiblePatchTestServicesHandler(w http.ResponseWriter, r *http.Request) {
|
func GetEligiblePatchTestServicesHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userID := chi.URLParam(r, "id")
|
userID := chi.URLParam(r, "id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +665,7 @@ type AddPatchTestRequest struct {
|
|||||||
func AddPatchTestHandler(w http.ResponseWriter, r *http.Request) {
|
func AddPatchTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userID := chi.URLParam(r, "id")
|
userID := chi.URLParam(r, "id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,7 +726,7 @@ type UserPatchTest struct {
|
|||||||
func GetUserPatchTestsHandler(w http.ResponseWriter, r *http.Request) {
|
func GetUserPatchTestsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userID := chi.URLParam(r, "user_id")
|
userID := chi.URLParam(r, "user_id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,7 +763,7 @@ func DeletePatchTestHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
userID := chi.URLParam(r, "user_id")
|
userID := chi.URLParam(r, "user_id")
|
||||||
testID := chi.URLParam(r, "test_id")
|
testID := chi.URLParam(r, "test_id")
|
||||||
if userID == "" || !validators.IsValidID(userID) {
|
if userID == "" || !validators.IsValidID(userID) {
|
||||||
http.Error(w, "User not found", http.StatusNotFound)
|
http.Error(w, "user not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if testID == "" || !validators.IsValidID(testID) {
|
if testID == "" || !validators.IsValidID(testID) {
|
||||||
|
|||||||
Reference in New Issue
Block a user