Share via


Retrieving Error Information

To retrieve error information

  1. Check whether the returned value represents an error that the object is prepared to handle.

  2. Call QueryInterface to get a pointer to the ISupportErrorInfointerface. 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.

  3. To get a pointer to the error object, call the GetErrorInfo function.

  4. To retrieve information from the error object, use the IErrorInfo methods.

The following figure illustrates this procedure.

isupporterrorinfo

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.

Error Handling Interfaces