mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Exceptit (#21864)
* more centralized exception handling * only remove when verboxse
This commit is contained in:
@@ -46,16 +46,7 @@ class CallbackModule(CallbackBase):
|
||||
self._print_task_banner(result._task)
|
||||
|
||||
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
||||
if 'exception' in result._result:
|
||||
if self._display.verbosity < 3:
|
||||
# extract just the actual error message from the exception text
|
||||
error = result._result['exception'].strip().split('\n')[-1]
|
||||
msg = "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: %s" % error
|
||||
else:
|
||||
msg = "An exception occurred during task execution. The full traceback is:\n" + result._result['exception']
|
||||
|
||||
self._display.display(msg, color=C.COLOR_ERROR)
|
||||
|
||||
self._handle_exception(result._result)
|
||||
self._handle_warnings(result._result)
|
||||
|
||||
if result._task.loop and 'results' in result._result:
|
||||
@@ -212,16 +203,9 @@ class CallbackModule(CallbackBase):
|
||||
self._display.display(msg, color=color)
|
||||
|
||||
def v2_runner_item_on_failed(self, result):
|
||||
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
||||
if 'exception' in result._result:
|
||||
if self._display.verbosity < 3:
|
||||
# extract just the actual error message from the exception text
|
||||
error = result._result['exception'].strip().split('\n')[-1]
|
||||
msg = "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: %s" % error
|
||||
else:
|
||||
msg = "An exception occurred during task execution. The full traceback is:\n" + result._result['exception']
|
||||
|
||||
self._display.display(msg, color=C.COLOR_ERROR)
|
||||
delegated_vars = result._result.get('_ansible_delegated_vars', None)
|
||||
self._handle_exception(result._result)
|
||||
|
||||
msg = "failed: "
|
||||
if delegated_vars:
|
||||
|
||||
Reference in New Issue
Block a user