move error outside of get_email

This commit is contained in:
Noah Swartz 2016-08-16 16:13:31 -07:00
parent 4a28bb1af7
commit 7767975204
2 changed files with 9 additions and 6 deletions

View file

@ -150,8 +150,14 @@ def perform_registration(acme, config):
return acme.register(messages.NewRegistration.from_data(email=config.email))
except messages.Error as e:
if e.typ == "urn:acme:error:invalidEmail":
config.namespace.email = display_ops.get_email(invalid=True)
return perform_registration(acme, config)
if config.noninteractive_mode:
msg = ("The email you specified was unable to be verified "
"by acme. Please ensure it is a valid email and "
"attempt registration again.")
raise erros.MissingCommandlineFlag(msg)
else:
config.namespace.email = display_ops.get_email(invalid=True)
return perform_registration(acme, config)
else:
raise

View file

@ -48,10 +48,7 @@ def get_email(invalid=False, optional=True):
invalid_prefix + msg if invalid else msg)
except errors.MissingCommandlineFlag:
msg = ("You should register before running non-interactively, "
"or provide --agree-tos and --email <email_address> flags. "
"If you have specified an email with the --email flag, "
"please make sure that you entered it correctly and the "
"domain is valid.")
"or provide --agree-tos and --email <email_address> flags.")
raise errors.MissingCommandlineFlag(msg)
if code != display_util.OK: