Add missing returns after HTTP errors
@@ -632,14 +632,14 @@ func (s *Service) handleStatus(w http.ResponseWriter, r *http.Request) {
}
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
- } else {
+ return
+ }
_, err = w.Write([]byte(b))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
-}
// handleNodes returns status on the other voting nodes in the system.
// This attempts to contact all the nodes in the cluster, so may take
@@ -725,14 +725,14 @@ func (s *Service) handleNodes(w http.ResponseWriter, r *http.Request) {
}
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
- } else {
+ return
+ }
_, err = w.Write([]byte(b))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
-}
// handleExecute handles queries that modify the database.
func (s *Service) handleExecute(w http.ResponseWriter, r *http.Request) {
@@ -794,10 +794,12 @@ func (s *Service) handleExecute(w http.ResponseWriter, r *http.Request) {
addr, err := s.store.LeaderAddr()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
}
if addr == "" {
stats.Add(numLeaderNotFound, 1)
http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable)
+ return
}
results, resultsErr = s.cluster.Execute(er, addr, timeout)
stats.Add(numRemoteExecutions, 1)
@@ -881,10 +883,12 @@ func (s *Service) handleQuery(w http.ResponseWriter, r *http.Request) {
addr, err := s.store.LeaderAddr()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
}
if addr == "" {
stats.Add(numLeaderNotFound, 1)
http.Error(w, ErrLeaderNotFound.Error(), http.StatusServiceUnavailable)
+ return
}
results, resultsErr = s.cluster.Query(qr, addr, timeout)
stats.Add(numRemoteQueries, 1)
