Retrieving Error Information
To retrieve error information
-
Check whether the returned value represents an error that the object is prepared to handle.
-
Call QueryInterface to get a pointer to the ISupportErrorInfo interface. Then, call InterfaceSupportsErrorInfo to verify that the error was raised by the object that returned it and that the error object pertains to the current error, and not to a previous call.
-
To get a pointer to the error object, call the GetErrorInfo function.
-
To retrieve information from the error object, use the IErrorInfo methods.
The following figure illustrates this procedure.
If the object is not prepared to handle the error, but needs to propagate the error information further down the call chain, it should simply pass the return value to its caller. Because the GetErrorInfo function clears the error information and passes ownership of the error object to the caller, the function should be called only by the object that handles the error.