The Orchestrator implementation of the Mozilla Rhino JavaScript Engine supports exception handling, to allow you to process errors. You must use the following guidelines when writing exception handlers in scripts.

  • Use the following European Computer Manufacturers Association (ECMA) error types. Use Error as a generic exception that plug-in functions return, and the following specific error types.

    • TypeError
    • RangeError
    • EvalError
    • ReferenceError
    • URIError
    • SyntaxError

    The following example shows a URIError definition.

    try { 
            throw new URIError("VirtualMachine with ID 'vm-0056' 
                           not found on 'vcenter-test-1'") ; 
    } catch ( e if e instanceof URIError ) { 
  • 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."
  • Write human readable messages as clearly as possible.
  • 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
  • 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