[orbitcpp-list] CORBA and C++ exceptions
Status: Beta
Brought to you by:
philipd
From: Petter R. <pe...@hu...> - 2000-01-11 12:37:03
|
Here is a small patch to implement the exception changes I suggested earlier. They are untested, but I belive this should work. This would make it possible to print the exception type to discover more on what went wrong. It also makes it possible to only check for superclass exception in the top level 'catch' statement. I'll test it this evening, but I thought I should ask if you think this is a good idea. diff -ur orbitcpp-0.24.1/orb/Exception.hh orbitcpp-0.24.1-pere/orb/Exception.hh --- orbitcpp-0.24.1/orb/Exception.hh Thu Sep 9 03:34:16 1999 +++ orbitcpp-0.24.1-pere/orb/Exception.hh Tue Jan 11 16:50:30 2000 @@ -37,15 +37,17 @@ #define _ORBIT_CPP_EXCEPTION_HH #include <orb/BasicTypes.hh> - +#include <exception> +#include <iostream> namespace CORBA { - class Exception { + class Exception : public exception { public: virtual ~Exception() {} virtual void _raise() = 0; + virtual const char* what() const { return "CORBA::Exception"; } protected: Exception() {} }; @@ -56,6 +58,7 @@ public: virtual ~UserException(); static UserException* _narrow(Exception* e); + virtual const char* what() const { return "CORBA::UserException"; } }; @@ -105,6 +108,8 @@ virtual const char * NP_RepositoryId() const { return ""; } + virtual const char* what() const { return "CORBA::SystemException"; } + protected: ULong pd_minor; CompletionStatus pd_status; @@ -114,6 +119,7 @@ class name : public SystemException { \ public: \ name(ULong minor, CompletionStatus status) : SystemException(minor, status) {} \ + virtual const char* what() const { return "CORBA::" #name; } \ }; @@ -148,6 +154,7 @@ CPPSYSEXC (INVALID_TRANSACTION) CPPSYSEXC (INV_POLICY) + extern ostream& operator<<(ostream& out, CORBA::Exception e&); }; diff -ur orbitcpp-0.24.1/orb/Exception.cc orbitcpp-0.24.1-pere/orb/Exception.cc --- orbitcpp-0.24.1/orb/Exception.cc Thu Feb 11 17:11:49 1999 +++ orbitcpp-0.24.1-pere/orb/Exception.cc Tue Jan 11 16:52:30 2000 @@ -55,3 +55,9 @@ return static_cast<SystemException*>(e); } + +ostream& +operator<<(ostream& out, CORBA::Exception e&) +{ + out << e.what() << endl; +} -- ##> Petter Reinholdtsen <## | pe...@td... O- <SCRIPT Language="Javascript">window.close()</SCRIPT> http://www.hungry.com/~pere/ | Go Mozilla, go! Go! |