[geos-devel] Making exceptions inherit from std::exception

Mark Coletti mcoletti at gmail.com
Wed Mar 9 21:41:23 EST 2005


It's a good idea to have all exceptions inherit from std::exception. 
std::exception classes provide a consistent exception handling
interface.  For example, I generally have the following in my code:

try
{
   foo();
}
catch( std::exception & e )
{
   const char * msg = e.what(); // debugger probe point
   throw e;  // rethrow so hopefully better handled upstream
}


That way I can generally quickly figure out what has happened in the
debugger.  Otherwise I'm left with this:

catch(...)
{
  // um?
}


So then it's back to unwinding the stack from the debugger.  Not hard,
just tedious.

I've made the changes to my local GEOS CVS; I've attached the diffs to
possibly be patched into the main branch.

Cheers,

Mark
-- 
I'm taking reality in small doses to build immunity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diffs
Type: application/octet-stream
Size: 4902 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/geos-devel/attachments/20050309/75aeee60/diffs.obj


More information about the geos-devel mailing list