当用户在组onOperationSucceeded时被调用,否则未经授权的异常“请求失败。访问被拒绝。您没有权限......”我怎样才能实现catch块被击中?
尝试{ var clientContext = SP.ClientContext.get_current();
groupCollection = clientContext.get_web().get_siteGroups();
group = groupCollection.getByName("VR-Administrators");
users = group.get_users();
clientContext.load(group);
clientContext.load(users);
currentUser = clientContext.get_web().get_currentUser();
clientContext.load(currentUser);
clientContext.executeQueryAsync(Function.createDelegate(this, onOperationSucceeded), Function.createDelegate(this, onOperationFailed));
}
catch(msg)
{
alert("Failed!" + msg);
}
答案 0 :(得分:1)
SP.ClientContext.executeQueryAsync method在服务器上执行当前待处理请求异步:
SP.ClientContext.executeQueryAsync(succeededCallback, failedCallback)
如果请求执行失败,则会调用failedCallback
。
在您的情况下,以下代码演示了如何处理System.UnauthorizedAccessException
异常:
function onOperationFailed(sender,args)
{
if(args.get_errorTypeName() == "System.UnauthorizedAccessException")
{
//Handle UnauthorizedAccessException here..
}
}