From: Ralf Jung <post@ralfj.de>
Date: Tue, 26 Jan 2016 13:13:42 +0000 (+0100)
Subject: try to get nicer exception messages when we fail fetching the checkip URL
X-Git-Url: https://git.ralfj.de/dyn-nsupdate.git/commitdiff_plain/2ded2634bd090dacf54effe51566cd3ab8c3aeaa

try to get nicer exception messages when we fail fetching the checkip URL
---

diff --git a/client-scripts/dyn-ns-client b/client-scripts/dyn-ns-client
index 175d880..0e96bed 100755
--- a/client-scripts/dyn-ns-client
+++ b/client-scripts/dyn-ns-client
@@ -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