-
Notifications
You must be signed in to change notification settings - Fork 5
Add error logging for negative scenarios to improve visibility #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -81,6 +81,7 @@ func GetCalculatedHashAndPercentHandler(w http.ResponseWriter, r *http.Request) | |||||
| } | ||||||
| jsonResponse, err := json.Marshal(response) | ||||||
| if err != nil { | ||||||
| log.WithFields(log.Fields{"error": err}).Error("failed to marshal JSON response") | ||||||
| http.Error(w, "Failed to marshal JSON response", http.StatusInternalServerError) | ||||||
| return | ||||||
| } | ||||||
|
|
@@ -99,6 +100,7 @@ func UpdatePercentFilterGlobalHandler(w http.ResponseWriter, r *http.Request) { | |||||
| // r.Body is already drained in the middleware | ||||||
| xw, ok := w.(*xwhttp.XResponseWriter) | ||||||
| if !ok { | ||||||
| log.Error("failed to cast responsewriter in UpdatePercentFilterGlobalHandler") | ||||||
| xhttp.AdminError(w, xwcommon.NewRemoteErrorAS(http.StatusInternalServerError, "responsewriter cast error")) | ||||||
| return | ||||||
| } | ||||||
|
|
@@ -149,6 +151,7 @@ func GetPercentFilterGlobalHandler(w http.ResponseWriter, r *http.Request) { | |||||
|
|
||||||
| globalpercent, err := GetPercentFilterGlobal(applicationType) | ||||||
| if err != nil { | ||||||
| log.WithFields(log.Fields{"error": err}).Error("failed to get global percent filter") | ||||||
| xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("unable to get globalpercent reponse. error: %v", err)) | ||||||
| return | ||||||
|
Comment on lines
152
to
156
|
||||||
| } | ||||||
|
|
@@ -209,6 +212,7 @@ func GetGlobalPercentFilterHandler(w http.ResponseWriter, r *http.Request) { | |||||
|
|
||||||
| globalpercent, err := GetGlobalPercentFilter(applicationType) | ||||||
| if err != nil { | ||||||
| log.WithFields(log.Fields{"error": err}).Error("failed to get global percent filter") | ||||||
| xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("unable to get globalpercent reponse. error: %v", err)) | ||||||
|
||||||
| xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("unable to get globalpercent reponse. error: %v", err)) | |
| xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("unable to get global percent response. error: %v", err)) |
Copilot
AI
Mar 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetGlobalPercentFilter currently always returns nil error, so this if err != nil branch is effectively dead/unreachable. Either return an actual error from GetGlobalPercentFilter (e.g., when DB calls fail) or simplify the API/handler to remove the unused error path.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -57,6 +57,7 @@ func PostRecookingLockdownSettingsHandler(w http.ResponseWriter, r *http.Request | |||||
| var lockdownSettingFromDB *common.LockdownSettings | ||||||
| lockdownSettingFromDB, err = lockdown.GetLockdownSettings() | ||||||
| if err != nil { | ||||||
| log.WithFields(log.Fields{"error": err}).Error("failed to get lockdown settings") | ||||||
| http.Error(w, err.Error(), http.StatusInternalServerError) | ||||||
|
||||||
| http.Error(w, err.Error(), http.StatusInternalServerError) | |
| xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handler returns an error message containing typos ("reponse"), which will be surfaced to API clients. Please correct the wording (and consider adding a space in "globalpercent" -> "global percent" for readability).