DO! NOT! SQUASH! TRACEBACKS!

This commit is contained in:
Pedro Algarvio 2018-11-23 11:33:44 +00:00
parent 59809a1e1b
commit 72205a5a38
No known key found for this signature in database
GPG Key ID: BB36BF6584A298FF
2 changed files with 18 additions and 8 deletions

View File

@ -1736,14 +1736,15 @@ class State(object):
try:
ret = self.states[cdata['full']](*cdata['args'],
**cdata['kwargs'])
except Exception:
except Exception as exc:
log.debug('An exception occurred in this state: %s', exc,
exc_info_on_loglevel=logging.DEBUG)
trb = traceback.format_exc()
ret = {
'result': False,
'name': name,
'changes': {},
'comment': 'An exception occurred in this state: {0}'.format(
trb)
'comment': 'An exception occurred in this state: {0}'.format(trb)
}
utc_finish_time = datetime.datetime.utcnow()
@ -1919,7 +1920,9 @@ class State(object):
self.states.inject_globals = {}
if 'check_cmd' in low and '{0[state]}.mod_run_check_cmd'.format(low) not in self.states:
ret.update(self._run_check_cmd(low))
except Exception:
except Exception as exc:
log.debug('An exception occurred in this state: %s', exc,
exc_info_on_loglevel=logging.DEBUG)
trb = traceback.format_exc()
# There are a number of possibilities to not have the cdata
# populated with what we might have expected, so just be smart
@ -1934,8 +1937,7 @@ class State(object):
'result': False,
'name': name,
'changes': {},
'comment': 'An exception occurred in this state: {0}'.format(
trb)
'comment': 'An exception occurred in this state: {0}'.format(trb)
}
finally:
if low.get('__prereq__'):

View File

@ -5,9 +5,15 @@ Decorators for salt.state
:codeauthor: :email:`Bo Maryniuk (bo@suse.de)`
'''
# Import Python libs
from __future__ import absolute_import, unicode_literals
import logging
# Import salt libs
from salt.exceptions import SaltException
log = logging.getLogger(__name__)
class OutputUnifier(object):
def __init__(self, *policies):
@ -24,12 +30,14 @@ class OutputUnifier(object):
for pls in self.policies:
try:
result = pls(result)
except Exception as ex:
except Exception as exc:
log.debug('An exception occurred in this state: %s', exc,
exc_info_on_loglevel=logging.DEBUG)
result = {
'result': False,
'name': 'later',
'changes': {},
'comment': 'An exception occurred in this state: {0}'.format(ex)
'comment': 'An exception occurred in this state: {0}'.format(exc)
}
return result
return _func