MDAC 2.5 SDK - OLE DB Programmer's Reference
Chapter 16: Errors
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:
- 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.
- 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).
- 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.
- 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.
- Call Release on the error object to release it.