ryank
11 years agoOccasional Contributor
Cross-Unit JScript Exceptions
I read in the SmartBear documentation here: Handling Exceptions in Scripts that TestComplete handles cross-unit exceptions in JScript except in certain cases. I followed another link to JScript Specifics and found that TestComplete cannot handle script exceptions thrown from a method of an object created in another Script Unit. I have the following case which does not meet that criteria but still isn't working:
Unit A
//USEUNIT UnitB
function main(){
doSomething(function(){
throw new Error("Test");
});
}Unit B
function doSomething(func){
try{
func.apply(null,[]);
}catch(e){
Log.Message(e.description)
}
}Since that does not fall under the category mentioned, it seems like this kind of thing should work. I get that it's kind of a weird construct. But it would be handy in our project if this kind of thing could work properly. Does anyone know in which cases cross-unit exceptions can be caught properly?