diff --git a/locales/en.json b/locales/en.json index 7ce7d2980..d2f3d7137 100644 --- a/locales/en.json +++ b/locales/en.json @@ -143,6 +143,7 @@ "domain_deleted": "The domain has been deleted", "domain_deletion_failed": "Unable to delete domain", "domain_dyndns_already_subscribed": "You've already subscribed to a DynDNS domain", + "domain_dyndns_dynette_is_unreachable": "Unable to reach YunoHost dynette, either your YunoHost is not correctly connected to the internet or the dynette server is down. Error: {error}", "domain_dyndns_invalid": "Invalid domain to use with DynDNS", "domain_dyndns_root_unknown": "Unknown DynDNS root domain", "domain_exists": "Domain already exists", diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index 191a2e79a..fe4349e58 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -87,19 +87,20 @@ def domain_add(auth, domain, dyndns=False): try: r = requests.get('https://dyndns.yunohost.org/domains') - except requests.ConnectionError: - pass + except requests.ConnectionError as e: + raise MoulinetteError(errno.EHOSTUNREACH, + m18n.n('domain_dyndns_dynette_is_unreachable', error=str(e))) + + dyndomains = json.loads(r.text) + dyndomain = '.'.join(domain.split('.')[1:]) + if dyndomain in dyndomains: + if os.path.exists('/etc/cron.d/yunohost-dyndns'): + raise MoulinetteError(errno.EPERM, + m18n.n('domain_dyndns_already_subscribed')) + dyndns_subscribe(domain=domain) else: - dyndomains = json.loads(r.text) - dyndomain = '.'.join(domain.split('.')[1:]) - if dyndomain in dyndomains: - if os.path.exists('/etc/cron.d/yunohost-dyndns'): - raise MoulinetteError(errno.EPERM, - m18n.n('domain_dyndns_already_subscribed')) - dyndns_subscribe(domain=domain) - else: - raise MoulinetteError(errno.EINVAL, - m18n.n('domain_dyndns_root_unknown')) + raise MoulinetteError(errno.EINVAL, + m18n.n('domain_dyndns_root_unknown')) try: yunohost.certificate._certificate_install_selfsigned([domain], False)