Error reporting helps you track and handle server errors. vCenter Server Web Services API server errors are reported as SOAP exceptions that contain a SoapFault object.

Using vSphere PowerCLI views provides additional error handling by translating the SoapFault object from the SoapException.Detail property into a MethodFault descendant object and throwing a VimException exception.

The following example illustrates a basic pattern implementation of error handling with vSphere PowerCLI views.

try {
			// call operations
		} catch (VimException ex) {
			if (ex.MethodFault is InvalidLogin) {
				 // Handle Invalid Login error
			} else {
					// Handle other server errors
			}
		} catch (Exception e) {
			// Handle user code errors
		}