| || |
Additional JScript Exception information
Right now I am trying to implement some error handling in my scripts such that my main logic is wrapped in a try-catch. Any exceptions will be output to the log as errors and the current test environment will be torn down so that the next test can start fresh.
I have all this working, but now I have the issue of losing the original location at which the exception occurred. The stack trace on the logged error identifies (correctly, of course) the root of the logged error as being in the catch block instead of in the try block where the exception occurred. Is there any way for me to access the stack trace for an exception after I have caught it?
I'd love an answer for this one as well. I've been using JScript with TestComplete for 8 years, and still not found a good way, aside from stepping through code, to track down exactly which line caused the error and still follow good coding practices to trap for any errors encountered. The JScript error object does not contain the line number where the error occurred, unless I'm missing something.
Does the section in the Help index:
Collecting Call Stack Information for Log Messages
provide anything for you go go by ?
No. That help topic points you to the CallStackSettings object, which only allows you to turn on or off the Call Stack logging to the test execution log. It does not provide you with the line number of the error that caused the error, or the line number where the error was logged. Somehow, the folks at SmartBear have figured out how to get the line number out of JScript, because they can include it in the Test Log. What's frustrating is that when I attempt to gracefully handle my scripting errors, the only pointer I get is that it happened in "foo" function, not where in "foo" the error occurred. If you don't care about being graceful, you can get the line number where the error occurred. I think it may be a limitation of the JScript engine.