Quantcast
Channel: New board topics in SmartBear Community
Viewing all articles
Browse latest Browse all 21061

Throwing exceptions in script extensions

$
0
0

Hi, 

 

I am learning to write a script extension in JScript. And I can't figure out how to throw an exception in the extension, and catch it in TestComplete. For example the following code in the script extension:

 

 

function GetError(){
throw new Error("Something went wrong"); }

When I call this code in TestComplete:

 

 

 

function TestExtension(){
  try{
    MyExtension.GetError();
  } catch(error){
    //Do something with the error
  }
}  

 

I expected error.description to return "Something went wrong". However, the error object I am getting is an empty object with no properties or methods at all.

 

Can anyone help me get this working?

 

I have read this article: http://support.smartbear.com/viewarticle/57510/

 

I am not really fond of using Log.Error instead because it may trigger the OnLogError event handler when you don't want to. 

 

I also dislike using the "last_status" approach. I want my code to fail when I get an uncaught exception in my code, not silently continue when I forget to add a status code check for every function call.

 

Regards,

Kevin 

 

 

 


Viewing all articles
Browse latest Browse all 21061

Trending Articles