Forum Discussion
merusso
15 years agoNew Contributor
Thanks for the response.
I saw that quote in the Try/Catch documentation about not catching errors in TestComplete methods, and without it, I would've simply assumed that I was doing something wrong or there was a bug.
The problem, from my understanding, with the "create an event handler" approach is that the script directly calling the TestComplete methods can't detect if an error occurred in the TestComplete method and handle or throw it.
If you create an event handler for onLogError, the script simply jumps to the onLogError function and executes from there. The call chain is lost, if I'm not mistaken.
So the solution seems to be to perform a check (like check if an object exists, and that it supports the given method, and any other possible errors that could occur) before calling a TestComplete method, and if those checks fail, throw an exception.
Again, it could be that I'm new. Maybe errors occurring in TestComplete methods should always signal a test failure worthy of breaking the call chain. I just have used a different methodology for test script creation in the past where the calling actions were always the first responsible party for handling errors of that nature.
I saw that quote in the Try/Catch documentation about not catching errors in TestComplete methods, and without it, I would've simply assumed that I was doing something wrong or there was a bug.
The problem, from my understanding, with the "create an event handler" approach is that the script directly calling the TestComplete methods can't detect if an error occurred in the TestComplete method and handle or throw it.
If you create an event handler for onLogError, the script simply jumps to the onLogError function and executes from there. The call chain is lost, if I'm not mistaken.
So the solution seems to be to perform a check (like check if an object exists, and that it supports the given method, and any other possible errors that could occur) before calling a TestComplete method, and if those checks fail, throw an exception.
Again, it could be that I'm new. Maybe errors occurring in TestComplete methods should always signal a test failure worthy of breaking the call chain. I just have used a different methodology for test script creation in the past where the calling actions were always the first responsible party for handling errors of that nature.