try to get nicer exception messages when we fail fetching the checkip URL
[dyn-nsupdate.git] / client-scripts / dyn-ns-client
index 175d88024259ac9702b27a473f05900de0ca0ed3..0e96bedb792e34cb79c35164eb240ebb7a94949a 100755 (executable)
@@ -63,7 +63,11 @@ def getMyIP(family, config, methods = {}, verbose = 0):
         return None
     elif method == 'web':
         server = config[family].get('server', config['DEFAULT']['server'])
-        ip = urlopen('https://'+server+'/checkip', config)
+        url = 'https://'+server+'/checkip'
+        try:
+            ip = urlopen(url, config)
+        except urllib.error.URLError:
+            raise Exception("Error fetching {}, make sure the URL is correct and the internet connection actually works.".format(url))
         if verbose >= VERBOSE_FULL:
             print("Server",server,"says my",family,"is",ip)
         return ip