'When an item in a task fails.'

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):
            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)
    msg = 'failed:    '
    if delegated_vars:
        msg += ('[%s    ->    %s]' % (result._host.get_name(), delegated_vars['ansible_host']))
    else:
        msg += ('[%s]' % result._host.get_name())
    self._display.display((msg + ('    (item=%s)    =>    %s' % (self._get_item(result._result), self._dump_results(result._result)))), color=C.COLOR_ERROR)
    self._handle_warnings(result._result)
