def get_field_name_from_mongoengine_error(exc):
    """
    Try to extract field name from mongoengine error.

    If field name is unable to be extracted, original exception is returned instead.
    """
    msg = str(exc)

    match = re.match('Cannot resolve field "(.+?)"', msg)

    if match:
        return match.groups()[0]

    return msg

    Try to extract field name from mongoengine error.

    If field name is unable to be extracted, original exception is returned instead.
    
st2common/st2common/util/misc.py