[omniORB] declaration bug affecting rethrowing of CORBA::Exception?
Bruce Visscher
visschb@rjrt.com
Thu, 08 Feb 2001 10:28:58 -0500
Huw,
Huw Rogers wrote:
>
> Hi,
>
> This code fails to compile on gcc 2.96/Linux and
> CC 5.0/Solaris:
>
> try {
> // some method invocation
> } catch (const CORBA::Exception &e) {
> // do something like print an error
> throw e;
> }
>
> gcc reports:
> CORBA::Exception::Exception (const CORBA::Exception &)' is
> protected within this context
>
> CC reports:
> Error: CORBA::Exception::Exception(const CORBA::Exception&) is not accessible from
> ...
>
> This is due to _MSC_VER not being defined
> at line 826 of omniORB3/CORBA.h (comment
> at that line indicates that this problem was experienced
> with MSVC++), which declares the copy ctor
> of CORBA:Exception public.
>
> This is probably a bug.
Actually, the error message is saving you from making a mistake. What
you are attempting to do is to "slice" the exception object, which is
probably not what you want to do. You should change your throw
statement to a rethrow (spelled "throw;", i.e., throw with no target
object) and I believe the errors will go away. More importantly, you
will be rethrowing the original object (or a complete copy of it) rather
than just the CORBA::Exception base object which doesn't have as much
information about the error.
I think the decision to make the copy constructor protected to catch
mistakes like this shows good design forethought.
HTH,
Bruce
--
Bruce Visscher visschb@rjrt.com
This message was intended for public consumption.
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.