What's wrong with this throw statement in JScript?
See the following code, copied from the else block of an if statement in a JScript script:
var err = new Error(); err.number = 1; err.name = "Could not close running Foo instance"; Log.Error(err.name, err.message, pmHigher, null, Sys.Desktop.Picture(), GetInfrastructuralLogID()); throw err;
I receive an Unspecified error during script execution when control transfers to the throw statement. The only extra information is that the error is located as column 1 (of this sample code). I saw such throw techniques used in TC help. What's wrong with mine?
I believe your code works as you intended. However keep this in mind:
In TestComplete, if a script calls an object method that is declared in another unit, and this method throws an exception, the exception cannot be caught and handled by the try {} block in the main script. Keep this in mind when developing object-oriented test scripts using native JScript functionality.
Source: https://support.smartbear.com/viewarticle/70308/
Check the example code under header "Using Objects Defined in Other Units".
I try to avoid exceptions and instead use event handlers because of this.