Browse Source

fix: use appropriate error message in GetGroupDetails based on status

Return "Group not found" only for 404, use "Failed to retrieve group"
for other error statuses instead of always saying "Group not found".
pull/8560/head
Chris Lu 20 hours ago
parent
commit
e814b23b48
  1. 7
      weed/admin/handlers/group_handlers.go

7
weed/admin/handlers/group_handlers.go

@ -97,7 +97,12 @@ func (h *GroupHandlers) GetGroupDetails(w http.ResponseWriter, r *http.Request)
group, err := h.adminServer.GetGroupDetails(r.Context(), name)
if err != nil {
glog.Errorf("Failed to get group details: %v", err)
writeJSONError(w, groupErrorToHTTPStatus(err), "Group not found")
status := groupErrorToHTTPStatus(err)
msg := "Failed to retrieve group"
if status == http.StatusNotFound {
msg = "Group not found"
}
writeJSONError(w, status, msg)
return
}
writeJSON(w, http.StatusOK, group)

Loading…
Cancel
Save