From 05c52da55980bda5358cc337878e27839d3fc6ba Mon Sep 17 00:00:00 2001 From: lhinds Date: Thu, 24 Aug 2017 19:32:38 +0100 Subject: [PATCH] Adds simple handler to provide failed line numbers Change adds `as err` handler to provide line number, if config yaml fails to parse. Example output [config] ERROR while scanning a simple key in "config.yaml", line 5, column 1 could not find expected ':' in "config.yaml", line 6, column 1 [main] ERROR config.yaml : Error parsing file. Change-Id: If764a123c0dd8871dcd98f58be48c6bf0034f1d4 Closes-Bug: #1621552 --- bandit/core/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bandit/core/config.py b/bandit/core/config.py index acde78ae..7369f061 100644 --- a/bandit/core/config.py +++ b/bandit/core/config.py @@ -49,7 +49,8 @@ class BanditConfig(object): try: self._config = yaml.safe_load(f) self.validate(config_file) - except yaml.YAMLError: + except yaml.YAMLError as err: + LOG.error(err) raise utils.ConfigError("Error parsing file.", config_file) # valid config must be a dict