@responder(pattern="^failed( (?P<num>\d+))?$", form='failed [num]',
 help="Display one or all failed tasks droned just performed for you")
def failed(conversation, num):
    failures = conversation.context.get('failures',[])

    droned_results = [f.value.resultContext for f in failures if f.check(DroneCommandFailed)]
    other_failures = [f for f in failures if not f.check(DroneCommandFailed)]

    if num: # Detailed error report
        droned_errors = [str(rc) for rc in droned_results]
        other_errors = [f.getTraceback() for f in other_failures]
        errors = droned_errors + other_errors

        num = int(num)
        try:
            conversation.say('\n' + errors[num], useHTML=False)
        except:
            conversation.say('No failure #%d' % num)
    elif failures: # Error summary listing
        droned_errors = ['%(server)s: %(description)s' % rc for rc in droned_results]
        other_errors = [str(f) for f in other_failures]
        errors = droned_errors + other_errors

        listing = '\n' + '\n'.join(i % "#%d %s" for i in enumerate(errors))
        conversation.say(listing, useHTML=False)
    else:
        conversation.say("I have not failed to do anything for you recently.")
dataset/ETHPy150Open OrbitzWorldwide/droned/droned/lib/droned/responders/core.py/failed/swapped operands of `%`