Clean up stacktrace when referenced map file doesn't exist

This commit is contained in:
rallytime 2015-07-28 17:15:31 -06:00
parent 823f0ce350
commit 3aa5045138
2 changed files with 9 additions and 5 deletions

View file

@ -1648,11 +1648,11 @@ class Map(Cloud):
return {}
if not os.path.isfile(self.opts['map']):
raise SaltCloudNotFound(
'The specified map file does not exist: {0}\n'.format(
self.opts['map']
)
log.error(
'The specified map file does not exist: \'{0}\''.format(
self.opts['map'])
)
raise SaltCloudNotFound()
try:
renderer = self.opts.get('renderer', 'yaml_jinja')
rend = salt.loader.render(self.opts, {})

View file

@ -83,7 +83,11 @@ class SaltCloud(parsers.SaltCloudParser):
self.exit(salt.defaults.exitcodes.EX_OK)
log.info('salt-cloud starting')
mapper = salt.cloud.Map(self.config)
try:
mapper = salt.cloud.Map(self.config)
except SaltCloudException as exc:
msg = 'There was an error generating the mapper.'
self.handle_exception(msg, exc)
names = self.config.get('names', None)
if names is not None: