Improve error handling to spare the server log from user's malformed requests and stop trying to parse data from providers if the HTTP status was not 200

This commit is contained in:
Ian Renton
2026-07-25 08:17:17 +01:00
parent 34e3933d5d
commit 2fc9658571
26 changed files with 169 additions and 128 deletions
+4 -4
View File
@@ -44,9 +44,9 @@ class KC2GProp(SolarConditionsProvider):
def _poll(self):
try:
logging.debug("Polling KC2G ionosonde data...")
response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30))
if response.status_code != 200:
logging.warning(f"KC2G ionosonde API returned HTTP {response.status_code}")
http_response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30))
if http_response.status_code != 200:
logging.warning(f"KC2G ionosonde API returned HTTP {http_response.status_code}")
return
now = datetime.now(timezone.utc)
@@ -57,7 +57,7 @@ class KC2GProp(SolarConditionsProvider):
ionosonde_data = dict(self._solar_conditions.ionosonde_data or {})
updated_count = 0
for reading in response.json():
for reading in http_response.json():
station = reading.get("station", {})
ursi = station.get("code")
name = station.get("name")