package routing import ( "fmt" "log" "net/http" "strings" ) func writeGeneralErrorJson(w http.ResponseWriter, status int, format string, a ...any) { msg := fmt.Sprintf(format, a...) log.Printf("General error: %s\n", msg) w.Header().Add("Content-Type", "application/json") w.WriteHeader(status) escapedMsg := strings.ReplaceAll(msg, `"`, `\"`) _, _ = w.Write([]byte(fmt.Sprintf(`{"GeneralError":"%s"}`, escapedMsg))) }