5.1

Table Of Contents
...
} catch ( e if e instanceof URIError ) {
}
n
All exceptions that scripts do not catch must be simple string objects of the form <type>:SPACE<human
readable message>, as the following example shows.
throw "ValidationError: The input parameter 'myParam' of type 'string' is too short."
n
Write human readable messages as clearly as possible.
n
Simple string exception type checking must use the following pattern.
try {
throw "VMwareNoSpaceLeftOnDatastore: Datastore 'myDatastore' has no space left" ;
} catch ( e if (typeof(e)=="string" && e.indexOf("VMwareNoSpaceLeftOnDatastore:") == 0) ) {
System.log("No space left on device") ;
// Do something useful here
}
n
Simple string exception type checking, must use the following pattern in scripted elements in workflows.
if (typeof(errorCode)=="string"
&& errorCode.indexOf("VMwareNoSpaceLeftOnDatastore:")
== 0) {
// Do something useful here
}
Orchestrator JavaScript Examples
You can cut, paste, and adapt the Orchestrator JavaScript examples to help you write JavaScripts for common
orchestration tasks.
For scripting examples specific to the JavaScript APIs that the different plug-ins provide, see Using vCenter
Orchestrator Plug-Ins.
n
Basic Scripting Examples on page 126
Workflow scripted elements, actions, and policies require basic scripting of common tasks. You can cut,
paste, and adapt these examples into your scripted elements.
n
File System Scripting Examples on page 127
Workflow scripted elements, actions, and policies require scripting of common file system tasks. You
can cut, paste, and adapt these examples into your scripted elements.
n
LDAP Scripting Examples on page 128
Workflow scripted elements, actions, and policies require scripting of common LDAP tasks. You can cut,
paste, and adapt these examples into your scripted elements.
n
Logging Scripting Examples on page 128
Workflow scripted elements, actions, and policies require scripting of common logging tasks. You can
cut, paste, and adapt these examples into your scripted elements.
n
Networking Scripting Examples on page 129
Workflow scripted elements, actions, and policies require scripting of common networking tasks. You
can cut, paste, and adapt these examples into your scripted elements.
n
Workflow Scripting Examples on page 129
Workflow scripted elements, actions, and policies require scripting examples of common workflow tasks.
You can cut, paste, and adapt these examples into your scripted elements.
Chapter 2 Scripting
VMware, Inc. 125