Okay, I don’t know if I’m being completely stupid here, but I can’t seem to get the try, catch blocks in SSJS in xpages to work. My code…
var labels = sessionScope.get(“BOOKINGLABELS”);
var links = sessionScope.get(“BOOKINGLINKS”);
var strReturn = “”;
try{
for(var x = 0; x<labels.length; x++){
strReturn=strReturn+"<a href=\"" + links[x] + "\">" + labels[x] + "</a><br/>";
}
return strReturn
}catch(e){
return "Error finding links, please re-save preferences";
}
I want to catch an array out of bound error in the for loop, but the server just reports “Array index out of range” if that happens, as if the catch block isn’t there at all.
If I insert a finally block, that executes okay, but never catch.
Any ideas?