Catching exceptions from the inet module in Tools.h++ Professional

Article ID: 1043
Last updated: 29 Jan, 2008
Article ID: 1043
Last updated: 29 Jan, 2008
Revision: 1
Views: 4483
Posted: 18 Jun, 1998
by --
Updated: 29 Jan, 2008
by
Problem


Specialized exceptions (such as RWInetHostNotFound) are not propagated out to the calling thread in the Tools.h++ Professional inet module. Exceptions are instead propagated as an RWxmsg.


Cause


The way exceptions are currently handled in the inet module is by using the RWIOUResult::setException(const RWCString& msg) method. If a specialized exception such as RWInetHostNotFound is thrown, the setException() method is called with the error message passed in as an RWCString.

The setException() method then creates a new RWxmsg object with the passed-in error string. This results in the exception being stored as an RWxmsg instead of the more specific error object (RWInetHostNotFound in this example).

When the exception propagates out to the calling thread, it is caught as an RWxmsg.


Action


This has been reported as a bug (bug ID #9504). If you must be able to catch and handle the specific exception that was thrown, you can test the RWXmsg::why() string like this:
catch (RWxmsg & x) 
{ 
 cout << RWxmsg caught:  << x.why () << endl; 

 if(RWCString(x.why()).contains(RWInetHostNotFound)
   cout << RWInetHostNotFound exception << endl;
 else
   cout << doesn't work << endl;
}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 1043
Last updated: 29 Jan, 2008
Revision: 1
Views: 4483
Posted: 18 Jun, 1998 by --
Updated: 29 Jan, 2008 by

Others in this category