Improve error reporting

This commit is contained in:
Ian Renton
2026-07-25 09:02:57 +01:00
parent c397009ada
commit 374a326874
17 changed files with 101 additions and 71 deletions
+2
View File
@@ -56,6 +56,8 @@ class HTTPAlertProvider(AlertProvider):
self.status = "Error" self.status = "Error"
logging.warning(f"HTTP {http_response.status_code} when calling {self.name} alerts API.") logging.warning(f"HTTP {http_response.status_code} when calling {self.name} alerts API.")
except ConnectionError:
logging.warning(f"Connection error when accessing {self.name} alerts API.")
except Exception: except Exception:
self.status = "Error" self.status = "Error"
logging.exception("Exception in HTTP JSON Alert Provider (" + self.name + ")") logging.exception("Exception in HTTP JSON Alert Provider (" + self.name + ")")
+10 -2
View File
@@ -153,6 +153,8 @@ class LookupHelper:
logging.warning(f"HTTP {response.status_code} when downloading Country-files.com cty.plist.") logging.warning(f"HTTP {response.status_code} when downloading Country-files.com cty.plist.")
return False return False
except ConnectionError:
logging.warning(f"Connection error when downloading Clublog cty.xml.")
except Exception as e: except Exception as e:
logging.error("Exception when downloading Clublog cty.xml", e) logging.error("Exception when downloading Clublog cty.xml", e)
return False return False
@@ -175,6 +177,8 @@ class LookupHelper:
logging.warning(f"HTTP {response.status_code} when downloading dxcc.json.") logging.warning(f"HTTP {response.status_code} when downloading dxcc.json.")
return False return False
except ConnectionError:
logging.warning(f"Connection error when downloading dxcc.json.")
except Exception as e: except Exception as e:
logging.error("Exception when downloading dxcc.json", e) logging.error("Exception when downloading dxcc.json", e)
return False return False
@@ -519,8 +523,10 @@ class LookupHelper:
except (KeyError, ValueError): except (KeyError, ValueError):
continue continue
except ConnectionError:
logging.warning(f"Connection error when looking up callsign %s using QRZ", lookup_call)
except Exception: except Exception:
logging.error("Exception when looking up QRZ data") logging.error("Exception when looking up callsign %s using QRZ", lookup_call)
return None return None
# Not found in QRZ; cache None so we don't keep retrying # Not found in QRZ; cache None so we don't keep retrying
@@ -578,8 +584,10 @@ class LookupHelper:
except (KeyError, ValueError): except (KeyError, ValueError):
continue continue
except ConnectionError:
logging.warning(f"Connection error when looking up callsign %s using HamQTH", lookup_call)
except Exception: except Exception:
logging.error("Exception when looking up HamQTH data") logging.error("Exception when looking up callsign %s using HamQTH", lookup_call)
return None return None
# Not found in HamQTH; cache None so we don't keep retrying # Not found in HamQTH; cache None so we don't keep retrying
+3 -1
View File
@@ -259,8 +259,10 @@ def populate_sig_ref_info(sig_ref):
else: else:
logging.warning("DME database did not contain data for ref %s", ref_id) logging.warning("DME database did not contain data for ref %s", ref_id)
except ConnectionError:
logging.warning("Connection error when looking up sig_ref info for " + sig + " ref " + ref_id)
except Exception: except Exception:
logging.warning("Exception when looking up sig_ref info for " + sig + " ref " + ref_id, exc_info=True) logging.error("Exception when looking up sig_ref info for " + sig + " ref " + ref_id, exc_info=True)
return sig_ref return sig_ref
@@ -127,11 +127,15 @@ class GIROIonosonde(SolarConditionsProvider):
from_str = from_time.strftime("%Y.%m.%d+%H:%M:%S") from_str = from_time.strftime("%Y.%m.%d+%H:%M:%S")
to_str = to_time.strftime("%Y.%m.%d+%H:%M:%S") to_str = to_time.strftime("%Y.%m.%d+%H:%M:%S")
url = f"{LGDC_URL}?ursiCode={ursi}&charName=foF2,MUFD,fmin&DMUF=3000&fromDate={from_str}&toDate={to_str}" url = f"{LGDC_URL}?ursiCode={ursi}&charName=foF2,MUFD,fmin&DMUF=3000&fromDate={from_str}&toDate={to_str}"
try:
http_response = requests.get(url, headers=HTTP_HEADERS, timeout=(5, 15)) http_response = requests.get(url, headers=HTTP_HEADERS, timeout=(5, 15))
if not http_response.ok: if not http_response.ok:
logging.warning(f"HTTP {http_response.status_code} when calling Giro ionosonde API.") logging.warning(f"HTTP {http_response.status_code} when calling Giro ionosonde API.")
return None, None, None return None, None, None
return self._parse_all(http_response.text) return self._parse_all(http_response.text)
except ConnectionError:
logging.warning("Connection error when accessing Giro ionosonde API.")
return None, None, None
@staticmethod @staticmethod
def _parse_all(text): def _parse_all(text):
@@ -51,6 +51,8 @@ class HTTPSolarConditionsProvider(SolarConditionsProvider):
self.status = "Error" self.status = "Error"
logging.warning(f"HTTP {http_response.status_code} when calling {self.name} solar conditions API.") logging.warning(f"HTTP {http_response.status_code} when calling {self.name} solar conditions API.")
except ConnectionError:
logging.warning(f"Connection error when accessing {self.name} solar conditions API.")
except Exception: except Exception:
self.status = "Error" self.status = "Error"
logging.exception("Exception in HTTP Solar Conditions Provider (" + self.name + ")") logging.exception("Exception in HTTP Solar Conditions Provider (" + self.name + ")")
+2
View File
@@ -115,6 +115,8 @@ class KC2GProp(SolarConditionsProvider):
self.last_update_time = datetime.now(pytz.UTC) self.last_update_time = datetime.now(pytz.UTC)
logging.debug(f"Updated KC2G ionosonde data for {updated_count} stations.") logging.debug(f"Updated KC2G ionosonde data for {updated_count} stations.")
except ConnectionError:
logging.warning("Connection error when accessing KC2G ionosonde API.")
except Exception: except Exception:
self.status = "Error" self.status = "Error"
logging.exception("Exception in KC2G ionosonde data provider") logging.exception("Exception in KC2G ionosonde data provider")
+6 -2
View File
@@ -1,3 +1,4 @@
import logging
import re import re
from datetime import datetime from datetime import datetime
@@ -35,6 +36,7 @@ class HEMA(HTTPSpotProvider):
new_spots = [] new_spots = []
# OK, if the spot seed actually changed, now we make the real request for data. # OK, if the spot seed actually changed, now we make the real request for data.
if spot_seed_changed: if spot_seed_changed:
try:
source_data = requests.get(self.SPOTS_URL, headers=HTTP_HEADERS, timeout=(5, 30)) source_data = requests.get(self.SPOTS_URL, headers=HTTP_HEADERS, timeout=(5, 30))
source_data_items = source_data.text.split("=") source_data_items = source_data.text.split("=")
# Iterate through source data items. # Iterate through source data items.
@@ -62,7 +64,9 @@ class HEMA(HTTPSpotProvider):
dx_latitude=float(spot_items[7]), dx_latitude=float(spot_items[7]),
dx_longitude=float(spot_items[8])) dx_longitude=float(spot_items[8]))
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other
# that for us. # code will do that for us.
new_spots.append(spot) new_spots.append(spot)
except ConnectionError:
logging.warning("Connection error when accessing HEMA spots API.")
return new_spots return new_spots
+2
View File
@@ -56,6 +56,8 @@ class HTTPSpotProvider(SpotProvider):
self.status = "Error" self.status = "Error"
logging.warning(f"HTTP {http_response.status_code} when calling {self.name} spot API.") logging.warning(f"HTTP {http_response.status_code} when calling {self.name} spot API.")
except ConnectionError:
logging.warning(f"Connection error when accessing {self.name} spots API.")
except Exception: except Exception:
self.status = "Error" self.status = "Error"
logging.exception("Exception in HTTP JSON Spot Provider (" + self.name + ")") logging.exception("Exception in HTTP JSON Spot Provider (" + self.name + ")")
+4
View File
@@ -1,3 +1,4 @@
import logging
from datetime import datetime from datetime import datetime
import requests import requests
@@ -33,6 +34,7 @@ class SOTA(HTTPSpotProvider):
new_spots = [] new_spots = []
# OK, if the epoch actually changed, now we make the real request for data. # OK, if the epoch actually changed, now we make the real request for data.
if epoch_changed: if epoch_changed:
try:
source_data = requests.get(self.SPOTS_URL, headers=HTTP_HEADERS, timeout=(5, 30)).json() source_data = requests.get(self.SPOTS_URL, headers=HTTP_HEADERS, timeout=(5, 30)).json()
# Iterate through source data # Iterate through source data
for source_spot in source_data: for source_spot in source_data:
@@ -55,4 +57,6 @@ class SOTA(HTTPSpotProvider):
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
# that for us. # that for us.
new_spots.append(spot) new_spots.append(spot)
except ConnectionError:
logging.warning("Connection error when accessing SOTA spots API")
return new_spots return new_spots
+1 -1
View File
@@ -76,7 +76,7 @@
</div> </div>
<script src="/js/add-spot.js?v=1784966035"></script> <script src="/js/add-spot.js?v=1784966577"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-add-spot").addClass("active"); $("#nav-link-add-spot").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -75,7 +75,7 @@
</div> </div>
<script src="/js/alerts.js?v=1784966035"></script> <script src="/js/alerts.js?v=1784966578"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-alerts").addClass("active"); $("#nav-link-alerts").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -75,8 +75,8 @@
<script> <script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %}; let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script> </script>
<script src="/js/spotsbandsandmap.js?v=1784966035"></script> <script src="/js/spotsbandsandmap.js?v=1784966577"></script>
<script src="/js/bands.js?v=1784966035"></script> <script src="/js/bands.js?v=1784966577"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-bands").addClass("active"); $("#nav-link-bands").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+5 -5
View File
@@ -1,6 +1,6 @@
{% extends "skeleton.html" %} {% extends "skeleton.html" %}
{% block head_extra %} {% block head_extra %}
<link rel="stylesheet" href="/css/style.css?v=1784966035" type="text/css"> <link rel="stylesheet" href="/css/style.css?v=1784966577" type="text/css">
<link href="/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet"> <link href="/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
<link href="/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet"> <link href="/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
<link href="/vendor/css/solid-6.7.2.min.css" rel="stylesheet"> <link href="/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
@@ -10,10 +10,10 @@
<script src="/vendor/js/bootstrap-5.3.8.bundle.min.js"></script> <script src="/vendor/js/bootstrap-5.3.8.bundle.min.js"></script>
<script src="/vendor/js/tinycolor2-1.6.0.min.js"></script> <script src="/vendor/js/tinycolor2-1.6.0.min.js"></script>
<script src="/js/utils.js?v=1784966035"></script> <script src="/js/utils.js?v=1784966577"></script>
<script src="/js/ui-ham.js?v=1784966035"></script> <script src="/js/ui-ham.js?v=1784966577"></script>
<script src="/js/geo.js?v=1784966035"></script> <script src="/js/geo.js?v=1784966577"></script>
<script src="/js/common.js?v=1784966035"></script> <script src="/js/common.js?v=1784966577"></script>
{% end %} {% end %}
{% block body %} {% block body %}
<div class="container"> <div class="container">
+1 -1
View File
@@ -284,7 +284,7 @@
</div> </div>
<script src="/vendor/js/chart-4.4.9.umd.min.js"></script> <script src="/vendor/js/chart-4.4.9.umd.min.js"></script>
<script src="/js/conditions.js?v=1784966035"></script> <script src="/js/conditions.js?v=1784966577"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-conditions").addClass("active"); $("#nav-link-conditions").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -95,8 +95,8 @@
<script> <script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %}; let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script> </script>
<script src="/js/spotsbandsandmap.js?v=1784966035"></script> <script src="/js/spotsbandsandmap.js?v=1784966578"></script>
<script src="/js/map.js?v=1784966035"></script> <script src="/js/map.js?v=1784966578"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-map").addClass("active"); $("#nav-link-map").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -116,8 +116,8 @@
<script> <script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %}; let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script> </script>
<script src="/js/spotsbandsandmap.js?v=1784966035"></script> <script src="/js/spotsbandsandmap.js?v=1784966577"></script>
<script src="/js/spots.js?v=1784966035"></script> <script src="/js/spots.js?v=1784966577"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-spots").addClass("active"); $("#nav-link-spots").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -59,7 +59,7 @@
</div> </div>
</div> </div>
<script src="/js/status.js?v=1784966035"></script> <script src="/js/status.js?v=1784966577"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$("#nav-link-status").addClass("active"); $("#nav-link-status").addClass("active");