Previous Table of Contents Next


19.9.16 Mapping Automation Exceptions to CORBA


   There are several ways in which an HRESULT (or SCODE) can be obtained by an Automation client such as the CORBA View. These ways differ based on the signature of the method and the behavior of the server. For example, for vtable invocations on dual interfaces, the HRESULT is the return value of the method. For IDispatch::Invoke invocations, the significant HRESULT may be the return value from Invoke, or may be in the EXCEPINFO parameter’s SCODE field.

   Regardless of how the HRESULT is obtained by the CORBA View, the mapping of the HRESULT is exactly the same as for COM to CORBA (see Section 18.3.10.2, “Mapping for COM Errors,? on page 18-44). The View raises either a standard CORBA system exception or the COM_HRESULT user exception.

   CORBA Views must supply an EXCEPINFO parameter when making IDispatch::Invoke invocations to take advantage of servers using EXCEPINFO. Servers do not use the EXCEPINFO parameter if it is passed to Invoke as NULL.

   An Automation method with an HRESULT return value and an argument marked as a [retval] maps to an IDL method whose return value is mapped from the [retval] argument. This situation is common in dual interfaces and means that there is no HRESULT available to the CORBA client. It would seem that there is a problem mapping S_FALSE scodes in this case because the fact that no system exception was generated means that the HRESULT on the vtable method could have been either S_OK or S_FALSE. However, this should not be a problem. A method in a dual interface should never attach semantic meaning to the distinction between S_OK and S_FALSE because a Visual Basic program acting as a client would never be able to determine whether the return value from the actual method was S_OK or S_FALSE.

   An Automation method with an HRESULT return value and no argument marked as [retval] maps to a CORBA interface with a long return value. The long HRESULT returned by the original Automation operation is passed back as the long return value from the CORBA operation.