[omniORB] Accessing the error message associated with an exce ption

jnye@micro-optics.com jnye@micro-optics.com
Thu, 7 Jun 2001 21:31:38 -0300


I ran into the same thing then I looked at the class definition for
CORBA::Exception and found a very nice (albeit non-portable) function that
returns the repository id. Here is an example:


try
{
...
}
catch (const CORBA::Exception & e)
{
    int size;
    cout << "CORBA Exception: " << e._NP_repoId(&size) << endl;
}

You'll see something like CORBA::COMM_ERROR or the repository Id for your
user-defined exceptions. _NP_repoId returns a const char *.

Cheers,
Jason.

-----Original Message-----
From: owner-omniorb-list@uk.research.att.com
[mailto:owner-omniorb-list@uk.research.att.com]On Behalf Of Len Holgate
(Mail List Account)
Sent: Thursday, June 07, 2001 7:04 PM
To: Bruce Fountain; omniorb-list@uk.research.att.com
Subject: Re: [omniORB] Accessing the error message associated with an
exception


I found that a problem too, I ended up using some code something like this
to get around it...

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


/**
 * Obtain the name of the exception that's been thrown.
 * We reuse an Omni orb macro that executes a supplied macro for
 * each of the CORBA exceptions.
 */

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


/**
 * Get the name of a CORBA::Exception as a string.
 * Uses some rather horrible macros to generate a text string from a
CORBA::Exception.
 */

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: "Bruce Fountain" <B_Fountain@motherwell.com.au>
To: <omniorb-list@uk.research.att.com>
Sent: Thursday, June 07, 2001 5:25 PM
Subject: [omniORB] Accessing the error message associated with an exception


> Hello again,
>
> I may be missing something obvious, but is there no method
> to convert a CORBA::SystemException to a string message? The
> other ORBs I have used have had some proprietory method like
> _to_string() or reason(). Is there some way of looking up the
> message using the minor() id?
>
> Bruce Fountain
> Mi Consulting Group (Australia) Pty Ltd
> Direct Line:  +61 (0)8 9368 8607
> Switchboard:  +61 (0)8 9368 8600
> Facsimile:    +61 (0)8 9368 8699
> E-mail: bruce.fountain@mi-services.com
>