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

Using 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 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
		}