嗨,我的代码正在生成一个 arrayoutofbound 异常,该异常在代码中被捕获,但代码突然终止。我希望代码继续。如果异常捕获 arrayoutofboundexception 或者我做错了什么,请帮助捕获错误。异常是预期的。下面是代码:-
try{
CsgLogin=Ldap.getdomain(requesterLoginId);//This returns domain\usernmae
LoginIDArray = CsgLogin.split("\\\\");
requesterLoginId = LoginIDArray[1]; //Exception generated here
} catch(Exception e) {
System.out.println("Error in the GLDAP lookup or error in Domain Mapping");
e.printStackTrace();
}
输出:
java.lang.ArrayIndexOutOfBoundsException: 1
at com.cs.ws.LdapConnect.getdomain(LdapConnect.java:131)
at com.cs.ws.AgentConnector.startOfBreakGlass(AgentConnector.java:476)
at com.cs.ws.AgentConnector.runBreakGlassProcess(AgentConnector.java:208)
at com.cs.ws.MyAccessTimer.main(MyAccessTimer.java:93)
Error in the GLDAP lookup or error in Domain Mapping
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1768)
at com.cs.ws.DomainMap.getDomain(DomainMap.java:21)
at com.cs.ws.AgentConnector.startOfBreakGlass(AgentConnector.java:477)
at com.cs.ws.AgentConnector.runBreakGlassProcess(AgentConnector.java:208)
at com.cs.ws.MyAccessTimer.main(MyAccessTimer.java:93)