william_diaz
12 years agoOccasional Contributor
Testcomplete 9.2 JScript Exception handling question.
I have the following code.
try
{
throw new Error("error...");
}
catch (e)
{
Log.Message( "Exception caught");
}
This works as expected. and the script completes succesfully.
but if the exception is thrown in a function higher in the stack.
try
{
funcA(); // funcA calls funcB() who calls funcC() who throws the exception.
}
catch (e)
{
Log.Message( "Exception caught");
}
The script stops and inform the user than an exception was thrown "Microsoft JScript runtime error..."
when I dismiss the dialog the script ends and the code in the catch is never executed.
if however in funcD I catch and rethrow the exception.
try
{
throw new Error(errorMessage);
}
catch (e)
{
Log.Message( "Exception caught, Rethrowing: " + errorMessage );
throw e;
}
I still get the dialog that halt the script but when I dismiss the dialog the execution resumes on the catch block that calls funcA. (first code posted). as one would expect. Any ideas?
Ideally I would like the stack to unwind and not get an Exception Dialog at all. even if I have to catch and rethrow, but even that code seems like a hack.
Thanks in advance.
try
{
throw new Error("error...");
}
catch (e)
{
Log.Message( "Exception caught");
}
This works as expected. and the script completes succesfully.
but if the exception is thrown in a function higher in the stack.
try
{
funcA(); // funcA calls funcB() who calls funcC() who throws the exception.
}
catch (e)
{
Log.Message( "Exception caught");
}
The script stops and inform the user than an exception was thrown "Microsoft JScript runtime error..."
when I dismiss the dialog the script ends and the code in the catch is never executed.
if however in funcD I catch and rethrow the exception.
try
{
throw new Error(errorMessage);
}
catch (e)
{
Log.Message( "Exception caught, Rethrowing: " + errorMessage );
throw e;
}
I still get the dialog that halt the script but when I dismiss the dialog the execution resumes on the catch block that calls funcA. (first code posted). as one would expect. Any ideas?
Ideally I would like the stack to unwind and not get an Exception Dialog at all. even if I have to catch and rethrow, but even that code seems like a hack.
Thanks in advance.