Add more info when parsing config fails

Previously when parsed config contained wrong values, the message didn't
say what option is wrong. The message looked like:
TypeError: option values must be strings

This patch adds some info to the message so it says which option,
section and value is wrong. Example:

TypeError: option values must be strings: section DEFAULT,
option api_paste_config, value: None

Change-Id: Iaed040c3af9ab10292eeb49b0522ab09b23e29f7
This commit is contained in:
Jakub Libosvar 2019-10-18 17:13:22 +02:00 committed by Brian Haley
parent 38fc3eb09c
commit 60ac055ff6
1 changed files with 11 additions and 1 deletions

View File

@ -68,5 +68,15 @@ class ConfigFileFixture(fixtures.Fixture):
if section != 'DEFAULT':
config_parser.add_section(section)
for option, value in section_dict.items():
config_parser.set(section, option, value)
try:
config_parser.set(section, option, value)
except TypeError as te:
raise TypeError(
"%(msg)s: section %(section)s, option %(option)s, "
"value: %(value)s" % {
'msg': te.args[0],
'section': section,
'option': option,
'value': value,
})
return config_parser