Cover exception handling in the utils.parsers

This commit is contained in:
Bo Maryniuk 2016-07-12 17:03:07 +02:00
parent 2cf696671f
commit 575767022b

View File

@ -38,6 +38,7 @@ import salt.utils.jid
from salt.utils import kinds
from salt.defaults import DEFAULT_TARGET_DELIM
from salt.utils.validate.path import is_writeable
import salt.exceptions
# Import 3rd-party libs
import salt.ext.six as six
@ -385,7 +386,12 @@ class SaltfileMixIn(six.with_metaclass(MixInMeta, object)):
'Loading Saltfile from \'{0}\''.format(self.options.saltfile)
)
saltfile_config = config._read_conf_file(saltfile)
try:
saltfile_config = config._read_conf_file(saltfile)
except salt.exceptions.SaltConfigurationError as error:
self.error(error.message)
self.exit(salt.defaults.exitcodes.EX_GENERIC,
'{0}: error: {1}\n'.format(self.get_prog_name(), error.message))
if not saltfile_config:
# No configuration was loaded from the Saltfile