mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-31 05:19:09 -07:00
Exceptit (#21864)
* more centralized exception handling * only remove when verboxse
This commit is contained in:
parent
89bf14e467
commit
b3251c9585
3 changed files with 19 additions and 28 deletions
|
@ -109,6 +109,20 @@ class CallbackBase:
|
|||
self._display.deprecated(**warning)
|
||||
del res['deprecations']
|
||||
|
||||
def _handle_exception(self, result):
|
||||
|
||||
if 'exception' in result:
|
||||
msg = "An exception occurred during task execution. "
|
||||
if self._display.verbosity < 3:
|
||||
# extract just the actual error message from the exception text
|
||||
error = result['exception'].strip().split('\n')[-1]
|
||||
msg += "To see the full traceback, use -vvv. The error was: %s" % error
|
||||
else:
|
||||
msg = "The full traceback is:\n" + result['exception']
|
||||
del result['exception']
|
||||
|
||||
self._display.display(msg, color=C.COLOR_ERROR)
|
||||
|
||||
def _get_diff(self, difflist):
|
||||
|
||||
if not isinstance(difflist, list):
|
||||
|
@ -197,6 +211,7 @@ class CallbackBase:
|
|||
if 'invocation' in result and task_name in ['debug']:
|
||||
del result['invocation']
|
||||
|
||||
|
||||
def set_play_context(self, play_context):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue