diff --git a/big-sort.go b/big-sort.go index 46e7c0e..28037b1 100644 --- a/big-sort.go +++ b/big-sort.go @@ -113,8 +113,12 @@ func getMovieData(title, year, apiKey string) (float64, error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - body, _ := io.ReadAll(resp.Body) - fmt.Printf("Failed request: URL: %s, Status Code: %d, Response: %s\n", url, resp.StatusCode, string(body)) + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + return 0, fmt.Errorf("failed to read response body: %w", err) + } + body := string(bodyBytes) + fmt.Printf("Failed request: URL: %s, Status Code: %d, Response: %s\n", url, resp.StatusCode, body) return 0, fmt.Errorf("failed request with status code: %d", resp.StatusCode) }