Share via


How an Automation Consumer Retrieves an Error Object

When an Automation consumer retrieves an error object in response to a return code it received, the consumer performs the following actions:

  1. If it does not already have an ISupportErrorInfo interface pointer on the component, the consumer can request one by calling QueryInterface on the component. ISupportErrorInfo must be supported by all components that create error objects.

  2. If it has not already determined whether the interface that returned the code supports error objects, the consumer calls ISupportErrorInfo::InterfaceSupportsErrorInfo and passes it the IID of the interface containing the method that returned the code. ISupportErrorInfo::InterfaceSupportsErrorInfo returns S_OK if the interface supports error objects (meaning the consumer should retrieve the current error object, if one exists) and returns S_FALSE if the interface does not support error objects (meaning the consumer should not retrieve the current error object because it applies to another interface and method).

  3. Call GetErrorInfo in the Automation DLL. This function returns an IErrorInfo interface pointer on the current error object and releases its reference count on the error object, transferring ownership of the error object to the consumer.

  4. Call the methods in the IErrorInfo interface to retrieve information from the error object. For example, IErrorInfo::GetDescription can be called to retrieve a text description of the error.

  5. Call Release on the error object to release it.