Previous Table of Contents Next


20.7.13 User Exceptions In COM


   In COM, all CORBA user exceptions used in an interface are represented by another interface, which contains one method per user exception. The value data for one of these exception interfaces is an encapsulated DCOM union where each member of the union is one of the exception definition structures. The discriminant values are the indices of the corresponding structure retrieval method from the user exception interface.

   module Bank

   { ... exception InsufFunds { float balance; }; exception InvalidAmount { float amount; };

   interface Account

   { exception NotAuthorized {};

   float Deposit(in float amount) raises(InvalidAmount);

   float Withdraw(in float amount) raises(InvalidAmount, NotAuthorized); }; };

   Per the COM/CORBA Part A specification, the above IDL results in the following interface used for user exceptions:

   struct Bank_InsufFunds { float balance; };struct Bank_InvalidAmount { float amount; };struct Bank_Account_NotAuthorized {};

   interface IBank_AccountUserExceptions : IUnknown

   {HRESULT get_InsufFunds([out] Bank_InsufFunds *);HRESULT get_InvalidAmount([out] Bank_InvalidAmount *);HRESULT get_NotAuthorized([out] Bank_Account_NotAuthorized *);

   };

   When this DCOM value object is passed, the value data is marshaled as the following data structure:

   union Bank_AccountUserExceptionsData switch(unsigned short)

   {case 0: Bank_InsufFunds m0;case 1: Bank_InvalidAmount m1;case 2: Bank_Account_NotAuthorized m2;

   };