User Tools

Site Tools


vrealize:general:errorhandling

Errorhandling in Scripts

vRO have a lot of “plugins” that have rather bad error handling, meaning that in many scripts you might need to parse the error to know how to handle it or to run some code around it. Guest operations is such an example. If you want to create a registry key in the guest VM, and it allready exists, a vRO workflow will stop (fatal error), but you might want to continue anyway. So understanding the exception object is essensial. The “Exception” or Error (witch is more correct) object is vRO is rather undocumented (I never found anything on it atleast), but it contains a “mix” of Microsoft and “Standard” javascript error handling.

Using the folllowing code:

try 
{
   Some Illegal code here
} 
catch (exception)
{
   System.log(exception);
} 

The actual exception object will have the following attributes: (With example error here)

exception.message = An error occurred because the specified guest registry key already exists. (Workflow:CreateInstallRegKeysForVM / Scriptable task (item1)#66)
exception.name = InternalError
exception.lineNumber = 66
exception.fileName = Workflow:CreateInstallRegKeysForVM / Scriptable task (item1)
exception.stack = at Workflow:CreateInstallRegKeysForVM / Scriptable task (item1):66 (CreateRegTree)
at Workflow:CreateInstallRegKeysForVM / Scriptable task (item1):90 (CreateRegEntry)
at Workflow:CreateInstallRegKeysForVM / Scriptable task (item1):281

Also rembember that the Exceptions object is an array of exception (inner most exception is the first in the list) so you might need to parse through all the exceptions (depending on your code)

for each (Exp in exception)
{
    // Compare here..
}

From this you can actually parse the error and repsond in a functional matter.

vrealize/general/errorhandling.txt · Last modified: 2018/11/29 12:37 by admin