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"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/mail"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -136,9 +135,8 @@ func RegisterHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Validate email format
|
||||
_, err := mail.ParseAddress(req.Email)
|
||||
if err != nil {
|
||||
http.Error(w, "invalid email format", http.StatusBadRequest)
|
||||
if err := validators.ValidateEmail(req.Email); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -687,7 +687,7 @@ func GetAllAdminBookingsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func GetAllBookingsByUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID := chi.URLParam(r, "user_id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -398,7 +398,7 @@ func ServicesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func ServicesEligibleForUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID := chi.URLParam(r, "user_id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ func ServicesEligibleForUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var dob time.Time
|
||||
err := db.DB.QueryRow(r.Context(), `SELECT date_of_birth FROM users WHERE id = $1`, userID).Scan(&dob)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -36,7 +36,7 @@ type TopService struct {
|
||||
func GetCustomerRelationshipHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID := chi.URLParam(r, "id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func GetCustomerRelationshipHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ func UpdateProfileHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func GetAdminUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID := chi.URLParam(r, "id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ func GetAdminUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
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) {
|
||||
userID := chi.URLParam(r, "id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -665,7 +665,7 @@ type AddPatchTestRequest struct {
|
||||
func AddPatchTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID := chi.URLParam(r, "id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ type UserPatchTest struct {
|
||||
func GetUserPatchTestsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID := chi.URLParam(r, "user_id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ func DeletePatchTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID := chi.URLParam(r, "user_id")
|
||||
testID := chi.URLParam(r, "test_id")
|
||||
if userID == "" || !validators.IsValidID(userID) {
|
||||
http.Error(w, "User not found", http.StatusNotFound)
|
||||
http.Error(w, "user not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if testID == "" || !validators.IsValidID(testID) {
|
||||
|
||||
Reference in New Issue
Block a user