5.5

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.
n
Basic Scripting Examples on page 132
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
Email Scripting Examples on page 133
Workflow scripted elements can include scripting of common email-related tasks. You can cut, paste,
and adapt these examples into your scripted elements.
n
File System Scripting Examples on page 135
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 135
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 136
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 136
Workflow scripted elements, actions, and policies require scripting of common networking tasks. You
can cut, paste, and adapt these examples into your scripted elements.
Chapter 2 Scripting
VMware, Inc. 131