From 2b89aa36472b9b82dc1021240f4ea5874a66fd08 Mon Sep 17 00:00:00 2001 From: Shekhar Vaidya Date: Fri, 10 Apr 2026 22:03:02 +0530 Subject: [PATCH] debug: add detailed MS API error logging --- backend/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/main.go b/backend/main.go index fe1aefa..a17b2b6 100644 --- a/backend/main.go +++ b/backend/main.go @@ -145,6 +145,7 @@ func enableCORS(next http.Handler) http.Handler { } func respondJSONError(w http.ResponseWriter, status int, message string) { + log.Printf("ERROR [%d]: %s\n", status, message) w.WriteHeader(status) json.NewEncoder(w).Encode(map[string]string{"error": message}) } @@ -194,7 +195,7 @@ func handleSkuInfo(w http.ResponseWriter, r *http.Request) { if resp.StatusCode != http.StatusOK { if attempt == 2 { - respondJSONError(w, http.StatusBadGateway, fmt.Sprintf("Microsoft API returned HTTP %d", resp.StatusCode)) + respondJSONError(w, http.StatusBadGateway, fmt.Sprintf("Microsoft API returned HTTP %d: %s", resp.StatusCode, string(bodyBytes))) return } continue @@ -296,7 +297,7 @@ func handleProxy(w http.ResponseWriter, r *http.Request) { bodyBytes, _ := io.ReadAll(resp.Body) if resp.StatusCode != http.StatusOK { - respondJSONError(w, http.StatusBadGateway, fmt.Sprintf("Microsoft API returned HTTP %d", resp.StatusCode)) + respondJSONError(w, http.StatusBadGateway, fmt.Sprintf("Microsoft API returned HTTP %d: %s", resp.StatusCode, string(bodyBytes))) return }