VMware Cloud Community
pabloramos
Enthusiast
Enthusiast
Jump to solution

Get Exception errors on a TokenID

I am using the workflow in this link: http://www.vcoteam.info/articles/learn-vco/176-how-to-retrieve-workflow-execution-details.html to retrieve workflow execution details. thanks Burke. I want to be able to also print out to System.log any "Exception" errors that occurred. How can I do that?

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Here is the same code with fixed parenthesis:

var tokens = requestFlow.executions; // Each execution is a "workflowToken" object

for each (token in tokens) {

  try {

    if (token.isStillValid) {

      System.log("");

      System.log("==== Checking token ====");

      System.log("Start Date: "+token.startDate);

      if (token.endDate != null) {

        System.log("End Date: "+token.endDate);

      }

      if (token.exception != null) {

        System.log("Exception: "+token.exception);

      }

    }

  } catch(ex) {

    System.log(ex)

  }

}

I also added a couple of lines to print the exception property of the workflow token (see the last System.log() statement above). I guess this is what you are interested in.

View solution in original post

Reply
0 Kudos
3 Replies
sbeaver
Leadership
Leadership
Jump to solution

Try and catch are the error handler you are looking for and would look something like this...

var tokens = requestFlow.executions; // Each execution is a "workflowToken" object

for each (token in tokens){

try{

  if (token.isStillValid){

    System.log("");

    System.log("==== Checking token ====");

    System.log("Start Date: "+token.startDate);

    if(token.endDate != null){

      System.log("End Date: "+token.endDate);

    }

}catch(ex){

System.log(ex)

}

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
pabloramos
Enthusiast
Enthusiast
Jump to solution

this code is giving me a syntax error with parenthesis and I can't figure out where the error is.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Here is the same code with fixed parenthesis:

var tokens = requestFlow.executions; // Each execution is a "workflowToken" object

for each (token in tokens) {

  try {

    if (token.isStillValid) {

      System.log("");

      System.log("==== Checking token ====");

      System.log("Start Date: "+token.startDate);

      if (token.endDate != null) {

        System.log("End Date: "+token.endDate);

      }

      if (token.exception != null) {

        System.log("Exception: "+token.exception);

      }

    }

  } catch(ex) {

    System.log(ex)

  }

}

I also added a couple of lines to print the exception property of the workflow token (see the last System.log() statement above). I guess this is what you are interested in.

Reply
0 Kudos