Overview
Features
Download
Documentation
Community
Add-Ons & Services

Problem with POCO_IMPLEMENT_EXCEPTION

Please post support and help requests here.

Problem with POCO_IMPLEMENT_EXCEPTION

Postby cx500tc » 06 Dec 2007, 15:29

The member function className in the macro POCO_IMPLEMENTATION_EXCEPTIOPN is defined and declared as such:

const char* CLS::className() const throw()
{
return typeid(*this).name();
}

But typeid could, in theory, create an exception bad_typeid, so why the throw(). In practice I understand the likelyhood of *this being null is 0 in this case. But wouldn't it better practice not to specify a throw() here?




cx500tc
 
Posts: 26
Joined: 24 Sep 2007, 17:48

Re: Problem with POCO_IMPLEMENT_EXCEPTION

Postby guenter » 07 Dec 2007, 15:00

I'm not quite sure why we have this declared as throw(), probably just to be consistent with name() and what().

You're right about the possible bad_typeid exception, which will be thrown by typeid if it is given a null pointer. However, the chance for this to happen is practically zero, as className() is virtual, so you'd have be particularly evil=minded to provoke this ;-)

I suggest for now to simply leave things as they are, as there are places (especially in client code) where an exception is implemented "manually", without using the macros, and changing the method signature would break that code.

guenter
 
Posts: 1107
Joined: 11 Jul 2006, 16:27
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests