mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Improve handling of empty JSON repsonses from ParksNPeaks (and potentially others)
This commit is contained in:
@@ -4,7 +4,7 @@ from threading import Event, Thread
|
||||
|
||||
import pytz
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout
|
||||
from requests.exceptions import ConnectionError, ConnectTimeout, JSONDecodeError, ReadTimeout
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from providers.spot.spot_provider import SpotProvider
|
||||
@@ -73,9 +73,14 @@ class HTTPSpotProvider(SpotProvider):
|
||||
logger.warning(f"HTTP {http_response.status_code} when calling {self.name} spot API.")
|
||||
|
||||
except ConnectionError:
|
||||
self.status = "Error"
|
||||
logger.warning(f"Connection error when accessing {self.name} spots API.")
|
||||
except (ConnectTimeout, ReadTimeout):
|
||||
self.status = "Error"
|
||||
logger.warning(f"Timeout when accessing {self.name} spots API.")
|
||||
except JSONDecodeError:
|
||||
self.status = "Error"
|
||||
logger.warning(f"Invalid or empty JSON response from {self.name} spots API.")
|
||||
except Exception:
|
||||
self.status = "Error"
|
||||
logger.exception(f"Exception in HTTP Spot Provider ({self.name})")
|
||||
|
||||
Reference in New Issue
Block a user