Forum Discussion

paulvinders's avatar
paulvinders
Contributor
8 years ago

How can I see the stacktrace when errors are catched using try catch finally?

Hi,

 

i'm calling a code sequence within a try-catch-finally block with TestExecute, e.g.:

 

function one()

{

  try
  {
     // call a function 'abc' which has an object error

     abc();

  }
  catch (exception)
  {
    Logger.Error("Message: " + exception.description);
  }
  finally
  {
    ...
  }

}

 

If an error occurs, I want to keep the prohram running and output the exception by using Logger.Error, but in the final logging, the Stacktrace / Additional Info tabs do not say where the original error occurred.

 

It says:

Test Unit     Name    Line No
Error           Logger  48

 

 

I would expect something like:

Test Unit     Name    Line No
Error           abc        5

 

Any ideas?

 

sincerely

Paul Vinders

SOPTIM AG

Germany

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    When you call Log.Error, do something like this:

    Log.Error ('Message: " + exception.description, exception.stack);

    What that will do is, in your Additional Info pane for your log entry, you will get the stack as reported from the JavaScript/JSCRIPT enginer
    • paulvinders's avatar
      paulvinders
      Contributor

      Hi,

       

      exception.stack is undefined. The Exception-Object has only the following fields: description, message, name, number

       

      sincerely

      Paul

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Is your project a JScript project or a JavaScript project? I may have made the wrong assumption that it is JavaScript. JScript I don't believe has the stack property but JavaScript, I believe, does.