Dispatch methods must always return an OLE status code as their first value. Return the constant $S-OK when there is no error. You can return a second value from a dispatch method to represent the result of executing the method. More than two result values are not meaningful.
See also "Dispatch method argument and return value types" on page 185.
The following general purpose error codes could be useful as the first return value from a dispatch method:
$E-UNEXPECTEDUnexpected failure.
$E-NOTIMPLNot implemented.
$E-OUTOFMEMORYRan out of memory.
$E-INVALIDARGOne or more arguments are invalid.
$E-POINTERInvalid pointer.
$E-HANDLEInvalid handle.
$E-ABORTOperation aborted.
$E-FAILUnspecified error.
$E-ACCESSDENIED You can convert a Windows error code, such as returned by the Windows function GetLastError, to a corresponding <SCODE> value with the function HRESULT-FROM-WIN32, page 229.
If <abort> is signalled during execution of the method (or a property getter or setter), a handler in the OLE-Automation library will catch it and return $E-ABORT to the client.