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

strk at refractions.net strk at refractions.net
Thu Mar 10 03:50:59 EST 2005


Mark, thanks for the contribution. I've been thinking about this
since the beginning, but changing it would mean another big break
of the API :(.

We are probably going to break it anyway before next release so 
I'd apply it nonetheless. Note though, that the patch lacks modification
of actual throws, as all GEOSexceptions (the Base class) are thrown by
pointer, not by reference, as the std::exception are.

--strk;

On Wed, Mar 09, 2005 at 09:41:23PM -0500, Mark Coletti wrote:
> 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.


> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel




More information about the geos-devel mailing list