Forum Discussion

scrier's avatar
12 years ago

Can't catch exceptions from extensions.


I have the following issue (somewhat simplified):

I have an extension in javascript that evaluates parameters in and if necessary throws an exception. Problem is that if the extension script throws the exception, TestComplete cannot catch it. Here is a simple test showing the issue:


function testThrow()


  throw new CustomException("Catch!!!");


function CustomException(text)





<?xml version="1.0" encoding="UTF-8"?>


  <ScriptExtension Name ="Test Object" Author="me" Version="0.1" HomePage="None">

    <Script Name ="extension.js">

      <RuntimeObject Name="Tests" Namespace="TEST">

        <Method Name="testThrow" Routine="testThrow">






testfunction in testcomplete:

function TestThrow()


  try {


  } catch(ex) {

    Log.Message( + ": " + ex.message);



I get the screenshot as listed below and it works if I throw in testcomplete, but not between extension and testcomplete.

// Andreas

2 Replies

  • Gordian's avatar
    Occasional Contributor
    I am also interested to know if this is a limitation.

    There is an internal variable as shown below that could be used and then checked by the user's script / keyword test.   Is that the recommended approach?

    var number;

    var last_status;  // An internal variable that holds the LastStatus property value

    // The set method of the Number property

    function SetNumber(Value)




        number = aqConvert.VarToInt(Value);

        last_status = 0;  // The property value has been successfully modified


      catch (e)


        last_status = e.number;  // An error indicating that Value could not be converted to an integer