Mercurial > p > roundup > code
diff roundup/admin.py @ 7076:d3d20e145cea
bug: cleaner error message on OptionUnsetError in initialize
We got a scary traceback when a:
roundup.configuration.OptionUnsetError
exception was raised during tracker.init(). Capture the exception and
raise a UsageError that is printed more cleanly. It now reads:
Error: In tracker/config.ini - MAIL_DOMAIN is not set and has no default
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 24 Nov 2022 20:57:17 -0500 |
| parents | 3211745e8d7c |
| children | 537b24c593af |
line wrap: on
line diff
--- a/roundup/admin.py Thu Nov 24 13:09:18 2022 -0500 +++ b/roundup/admin.py Thu Nov 24 20:57:17 2022 -0500 @@ -35,7 +35,7 @@ from roundup import date, hyperdb, init, password, token from roundup import __version__ as roundup_version import roundup.instance -from roundup.configuration import (CoreConfig, NoConfigError, +from roundup.configuration import (CoreConfig, NoConfigError, OptionUnsetError, ParsingOptionError, UserConfig) from roundup.i18n import _, get_translation from roundup.exceptions import UsageError @@ -616,8 +616,12 @@ tracker.nuke() # GO - tracker.init(password.Password(adminpw, config=tracker.config), - tx_Source='cli') + try: + tracker.init(password.Password(adminpw, config=tracker.config), + tx_Source='cli') + except OptionUnsetError as e: + raise UsageError("In %(tracker_home)s/config.ini - %(error)s" % { + 'error': str(e), 'tracker_home': tracker_home }) return 0
