Forum Discussion

gus's avatar
gus
Contributor
10 years ago

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....
  • k_de_boer03's avatar
    10 years ago

    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.