I'm trying to set error messages for my custom tasks when some unexpected error occurs. From the vSphere 5.5 docs, I understand I need to invoke Task.setTaskState with the following parameters:
_this ManagedObjectReference // reference to task
state TaskInfoState // must be TaskInfoState.ERROR for errors
result xsd:anyType // valid only if TaskInfo.State.success SKIP
fault MethodFault // must directly or indirectly extend VimFault
In the Eclipse IDE, the method VimPortType.setTaskState says the final argument is of type LocalizedMethodFault, not MethodFault. So, I created a LocalizedMethodFault variable and set its properties. One property setter is setFault, which takes a MethodFault. I know VimFault extends MethodFault, so I create a VimFault instance and use with setFault.
However, I see VimFault has a setter setFaultCause, which takes an argument of, LocalizedMethodFault. So this fault assignment is starting to get recursive.
LocalizedMethodFault fault = new LocalizedMethodFault();
VimFault vimFault = new VimFault();
fault.setDynamicType("Runtime Error");
fault.setLocalizedMessage(message);
fault.setFault(vimFault);
vimFault.setDynamicType("Runtime Error");
vimFault.setFaultCause(fault);
In any case, I tried to use this code but it did not work. Any ideas or example code that works would be greatly appreciated.
-E
↧
Custom Task setTaskState Error example
↧