From ba58cd752770a041bd0004b4895bc4e5efc3eda4 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Sun, 6 Dec 2015 17:31:00 -0800 Subject: [PATCH] genconfig: Debug info for unknown config types When doing a 'tox -egenconfig' and an option type is unknown improve the debug information that is generated to make it easier to debug and fix this issue. Change-Id: If76908190e4cb9955c0a0c022bab31f1088ec026 --- ironic/common/config_generator/generator.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ironic/common/config_generator/generator.py b/ironic/common/config_generator/generator.py index c6c1c15898..c2d2703ecf 100644 --- a/ironic/common/config_generator/generator.py +++ b/ironic/common/config_generator/generator.py @@ -268,11 +268,12 @@ def _print_opt(opt, group): if not opt_help: sys.stderr.write('WARNING: "%s" is missing help string.\n' % opt_name) opt_help = "" - try: - opt_type = OPTION_REGEX.search(str(type(opt))).group(0) - except (ValueError, AttributeError) as err: - sys.stderr.write("%s\n" % err) - sys.exit(1) + result = OPTION_REGEX.search(str(type(opt))) + if not result: + raise ValueError( + "Config option: {!r} Unknown option type: {}\n".format( + opt_name, type(opt))) + opt_type = result.group(0) opt_help = u'%s (%s)' % (opt_help, OPT_TYPES[opt_type]) print('#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH)))