def METHOD_NAME(hresult, msg):
    for k in known_error_patterns.keys():
        if re.search(k, msg, re.IGNORECASE):
            return None, known_error_patterns[k]
    # if we cannot determine the type or error based on the msg, try to look it up by its hresult
    # this will be true for error messages like 'Invalid connection string attribute'
    if hresult:
        res = known_hresult_codes.get(hresult)
        if res and len(res) == 2:
            return res[0], res[1]
    return None, ConnectionErrorCode.unknown