[omniORB] Getting something out of an exception

Len Holgate (Mail List Account) Mail-lists@dial.pipex.com
Fri, 7 Sep 2001 23:00:35 +0100


Or, something like this works, though I guess it's a bit of a brute force
approach...

#ifndef __OMNIORB_USEREXCEPTION_H__
#include <omniORB3/userexception.h>
#endif


#define DoThis(_ex)                                                  \
   if (CORBA::_ex::_narrow(const_cast<CORBA::Exception *>(&e)))      \
   {                                                                 \
      return "CORBA::" #_ex;                                         \
   }                                                                 \

static std::string GetNameFromCORBAException(const CORBA::Exception &e)
{
   OMNIORB_FOR_EACH_SYS_EXCEPTION(DoThis)

   if (CORBA::UserException::_narrow(const_cast<CORBA::Exception *>(&e)))
   {
      return "CORBA::UserException";
   }

   return "Unrecognised CORBA::Exception!";
}



----- Original Message -----
From: "Visscher, Bruce" <VISSCHB@RJRT.com>
To: "'ERIKSSON,TOBIAS (A-Sweden,ex1)'" <tobias_eriksson@agilent.com>;
<omniorb-list@uk.research.att.com>
Sent: Friday, September 07, 2001 12:00 AM
Subject: RE: [omniORB] Getting something out of an exception


> Tobias,
>
> Probably, the best bet if you really don't know what to expect is to use
RTTI.  I.e,
> provided you have compiled with RTTI enabled, display the
typeid(e).name().
>
> BTW (to the omniORB developers), do the default omniORB compiler switches
still exclude the
> enabling of RTTI (-GR) on the NT platform?  I never liked that idea.  I
realize that one use
> of RTTI is for up casting and it could be argued that this isn't
appropriate in a CORBA C++
> environment (we're supposed to use narrow, not dynamic_cast), but I have
found the ability
> to report the exact name of an exception to be (extremely) useful.  If you
try to do this
> (invoke typeid to get the type name) and RTTI isn't enabled then the C++
Run Time Library
> sends a rather unfriendly message to the user.
>
> Bruce
>
> -----Original Message-----
> From: ERIKSSON,TOBIAS (A-Sweden,ex1)
> [mailto:tobias_eriksson@agilent.com]
> Sent: Thursday, September 06, 2001 8:45 AM
> To: omniorb-list@uk.research.att.com
> Subject: [omniORB] Getting something out of an exception
>
>
> Hi
>  I'm receiving a CORBA::SystemException but I do not know why, isn't there
> any variable that can give me some hint on what wet wrong?
>
>  Regards
>   Tobias
>