@staticmethod
def _get_exception_from_thrift_result(result):
    """Returns the wrapped exception, if pressent. None if not.

        result is a generated *_result object. This object either has a
        'success' field set indicating the call succeeded, or a field set
        indicating the exception thrown.
        """
    fields = result.__dict__.keys() if hasattr(result, '__dict__'
        ) else result.__slots__
    for field in fields:
        value = getattr(result, field)
        if value is None:
            continue
        elif field == 'success':
            return None
        else:
            return value
    return None
