Error Handling Strategies
Because interface methods are virtual, it is not possible for a caller to know the full set of values that may be returned from any one call. One implementation of a method may return five values; another may return eight.
The documentation lists common values that may be returned for each method; these are the values that you must check for and handle in your code because they have special meanings. Other values may be returned, but because they are not meaningful, you do not need to write special code to handle them. A simple check for zero or nonzero is adequate.
The return value of COM functions and methods is an HRESULT. The values of some HRESULTs have been changed in COM to eliminate all duplication and overlapping with the system error codes. Those that duplicate system error codes have been changed to FACILITY_WIN32, and those that overlap remain in FACILITY_NULL. Common HRESULT values and their values are listed in the following table.
||The operation was aborted because of an unspecified error.
||A general access-denied error.
||An unspecified failure has occurred.
||An invalid handle was used.
||One or more arguments are invalid.
||The QueryInterface method did not recognize the requested interface. The interface is not supported.
||The method is not implemented.
||The method failed to allocate necessary memory.
||The data necessary to complete the operation is not yet available.
||An invalid pointer was used.
||A catastrophic failure has occurred.
||The method succeeded and returned the boolean value FALSE.
||The method succeeded. If a boolean return value is expected, the returned value is TRUE.
If the first four digits of the error code are 8007, this indicates a system or network error. You can use the net command to decode these types of errors. To decode the error, first convert the last four digits of the hexadecimal error code to decimal. Then, at the command prompt, type the following, where decimal code is replaced with the return value you want to decode:
net helpmsg <decimal_code>
The net command returns a description of the error. For example, if COM returns the error 8007054B, convert the 054B to decimal (1355). Then type the following:
net helpmsg 1355
The net command returns the error description: "The specified domain did not exist".