def failure_to_dict(failure):
    """Attempts to convert a failure object into a jsonifyable dictionary."""
    failure_dict = failure.to_dict()
    try:
        # it's possible the exc_args can't be serialized as JSON
        # if that's the case, just get the failure without them
        jsonutils.dumps(failure_dict)
        return failure_dict
    except (__HOLE__, ValueError):
        return failure.to_dict(include_args=False)
dataset/ETHPy150Open openstack/taskflow/taskflow/engines/worker_based/protocol.py/failure_to_dict