improve errorhandling in get_ntp

This commit is contained in:
tke
2024-05-06 07:47:47 +02:00
parent 26d62c0887
commit 93dadb9ba9

View File

@@ -6,5 +6,8 @@ c = ntplib.NTPClient()
try:
response = c.request(sys.argv[1])
print(ctime(response.tx_time))
except:
print("ERROR")
except ntplib.NTPException as e:
print(f"ERROR during NTP request: {e}")
print("Usage: ntp-client.py <hostname>")
sys.exit(-1)