Except block now covers specific errors

Previously too broad exception has been refactored,
in order to stop truly unexpected issues from hiding.

Only ParsingError and OSError is now caught by the block.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I685b6b325fc2c252cb7e656f369a60f958fa72bf
This commit is contained in:
Jiri Podivin 2021-04-15 13:43:18 +02:00
parent 3d6e5a1962
commit 2470d54bbd
1 changed files with 1 additions and 1 deletions

View File

@ -60,7 +60,7 @@ def get_result(path, section, key, default=None):
try:
config.read(path)
except Exception:
except (OSError, ConfigParser.ParsingError):
msg = "The file '{}' is not in a valid INI format.".format(path)
ret = ReturnValue.INVALID_FORMAT
return (ret, msg, value)