try to get nicer exception messages when we fail fetching the checkip URL
authorRalf Jung <post@ralfj.de>
Tue, 26 Jan 2016 13:13:42 +0000 (14:13 +0100)
committerRalf Jung <post@ralfj.de>
Tue, 26 Jan 2016 13:13:42 +0000 (14:13 +0100)
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'])
         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
         if verbose >= VERBOSE_FULL:
             print("Server",server,"says my",family,"is",ip)
         return ip