Improve error handling across deal sources and increase CheapShark page size
Add proper error handling for price parsing, date parsing, and HTTP status codes in CheapShark, Epic, and ITAD integrations. Fix Epic dedup IDs to distinguish current vs upcoming offers. Bump CheapShark fetch page size from 10 to 60. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -166,6 +166,12 @@ func LookupHistoricalLows(apiKey string, steamAppIDs []string) (map[string]bool,
|
||||
continue
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
slog.Warn("itad lookup returned non-200", "appid", appID, "status", resp.StatusCode)
|
||||
resp.Body.Close()
|
||||
continue
|
||||
}
|
||||
|
||||
var lookup struct {
|
||||
Found bool `json:"found"`
|
||||
Game struct {
|
||||
@@ -195,7 +201,10 @@ func LookupHistoricalLows(apiKey string, steamAppIDs []string) (map[string]bool,
|
||||
itadToSteam[itadID] = steamID
|
||||
}
|
||||
|
||||
body, _ := json.Marshal(gameIDs)
|
||||
body, err := json.Marshal(gameIDs)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("itad overview marshal failed: %w", err)
|
||||
}
|
||||
url := fmt.Sprintf("https://api.isthereanydeal.com/games/overview/v2?key=%s", apiKey)
|
||||
resp, err := http.Post(url, "application/json", bytes.NewReader(body))
|
||||
if err != nil {
|
||||
@@ -203,6 +212,10 @@ func LookupHistoricalLows(apiKey string, steamAppIDs []string) (map[string]bool,
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return result, fmt.Errorf("itad overview returned status %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
var overview struct {
|
||||
Prices []struct {
|
||||
ID string `json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user