The COM interface always masks the exception message with a "catastrophic failure",

I have a Delphi ActiveX project with 4 interfaces. Two of them have AutoComObject factories for their CoClasses. All interface methods are declared using safecalls. On factory interfaces, if an exception is thrown in any method, the caller receives an EOleException with an exception message from the original exception in activex. But in the other two interfaces, any exception is masked as an EOleException with a message disguised as "Catastrophic Error."

Does anyone know why this is happening, and how to make the original exception message not mask?

+4
source share
1 answer

If an unhandled exception excludes the method safecallfor the class, it TObject.SafeCallException()is called to convert the exception into an HRESULTerror code, which is then returned to COM to the caller. By default it TObject.SafeCallException()always returns E_UNEXPECTED( $8000FFFF). A class can override SafeCallException()to return more meaningful HRESULT. TComObjectand TAutoIntfObjectthey do just that, for example (they also call SetErrorInfo()in order to set detailed information about the exception that the caller can get with help GetErrorInfo()if desired). Thus, it seems that your two objects with AutoComObjecthave an implementation SafeCallException(), and your other two objects are not working.

+8
source

All Articles